@sachin123456 wrote:
Hi here is my code -
I am writing to csv and when i ran getting the below errordef CSVCreate(file_name):
now = datetime.datetime.now()
my_file = Path(“C:\Users\SJainOF2973\Desktop\LM_Girish\day19_11\Processsed_CSV.csv”)dfr=pd.read_excel(file_name,sheet_name='CHANGE LOG',usecols=(0,1)) dfr['Updated_Date']=dfr['Date'] dfr=dfr.drop(['Date'],axis=1) dfr['Processed_Date']=now dfr['File_Name']=file_name if not os.path.isfile('my_file'): dfr.to_csv(my_file, header='column_names') else: dfr.to_csv(my_file, mode='a', header=False) my_file.close()
CSVCreate(file_name)
Error:
AttributeError: ‘WindowsPath’ object has no attribute ‘close’have tried providing my_file.close at the end but no luck.
Any leadsThanks in Advance.
Sachin
Posts: 1
Participants: 1