I'm trying to convert files from CSV format to xlsx format by a Batchwise conversion method. I need to convert all the CSV files in a folder to xlsx in one go. The relevant part of the code I used is given here.
#import the library
from csvkit import convert
#Convert to xlsx
with open(csv_path,'rb') as csv_file:
with open(xlsx_path,'wb') as xlsx_file:
conv(csv_file,xlsx_file,'xlsx',encoding = 'utf-8')
This gives me the following error
TypeError Traceback (most recent call last)
Cell In[10], line 29
27 with open(csv_path,'rb') as csv_file:
28 with open(xlsx_path,'wb') as xlsx_file:
---> 29 conv(csv_file,xlsx_file,'xlsx',encoding = 'utf-8')
31 print(f"Converted {file} to {xlsx_file}")
33 print("Conversion complete!")
TypeError: 'module' object is not callable
Is it possible to convert CSV to XLSX by this method? Please let me know if the problem is with the approach or if any change in the code will help. My goal is to create new XLSX files corresponding to each CSV file in a particular folder. Any other simple solutions for this will be very helpful.