I did not open the file anywhere, I directly defined it in line 22. DO I need to modify the code? can you please suggest whre (and how) to change it. Below is my complete code.
import logging import pandas as pd from datetime import datetime class MyData: def __init__(self): self.mode = None def read_data(self, inFile, colNames, mode): try: df_tmp = pd.read_csv(inFile) print(df_tmp.head(2)) logging.debug("Read data successfully") data.mod_data() except OSError as e: logging.debug("File read fail check fail reason below") logging.debug(e.errno) def mod_data(self): print("New Df.......") print(self.df) logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)04d:%(levelname)s: %(message)s', filename=('mylog'+datetime.today().strftime('%Y%m%d_%H%M%S')+".txt"), filemode='w',datefmt='%Y-%m-%d %H:%M:%S') logging.debug("Hello new log") logging.debug("Initialize file read...") data = MyData() data.read_data(csvfile = r'HATY.csv', cols = 'col1', opmode = 'NOM')