From ff4ca8eeb293262b7bc9fbb8f348e8e4a5a44cff Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 11 Dec 2023 21:59:35 -0300 Subject: [PATCH] (feat) add read csv util --- utils/os_utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils/os_utils.py b/utils/os_utils.py index 5310e42..e0ff6c3 100644 --- a/utils/os_utils.py +++ b/utils/os_utils.py @@ -3,6 +3,8 @@ import subprocess import importlib.util import inspect import os + +import pandas as pd from hummingbot.smart_components.strategy_frameworks.directional_trading import DirectionalTradingControllerBase, DirectionalTradingControllerConfigBase import yaml @@ -151,3 +153,12 @@ def execute_bash_command(command: str, shell: bool = True, wait: bool = False): process = subprocess.Popen(command, shell=shell) if wait: process.wait() + + +def safe_read_csv(path): + try: + df = pd.read_csv(path) + except pd.errors.ParserError as e: + print("Error occurred while reading CSV:", str(e)) + df = pd.DataFrame() + return df