I created class method to easen file reading. But the end result gives me error of file_read=Read_file.file_reading_through_class('./ConfigurationFile/configFile.csv') TypeError: Read_file.file_reading_through_class() missing 1 required positional argument: 'fileName'
the code is below;
import pandas as pd
import sys,os, time,re
class Read_file():
def file_reading_through_class(self,fileName):
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
path_actual = os.getcwd()
path_main_folder = path_actual[:-4]
path_result = path_main_folder + fileName
print('frozen path', os.path.normpath(path_result))
file_to_read = pd.read_json(path_result)
return file_to_read
else:
file_to_read = pd.read_json(fileName)
return file_to_read
file_read=Read_file.file_reading_through_class('./ConfigurationFile/configFile.csv')
>Solution :
You will need to instantiate the class first.
self refers to the instance of the class.
rf = Read_file()
file_read = rf.file_reading_through_class('./ConfigurationFile/configFile.csv')
Or you can mark your function as a static method, and you can use your function the way you are using it.
@staticmethod
def file_reading_through_class(fileName):