Convert Large Csv File To Excel Using Python 3
this is my code covert CSV file to .xlsx file, for small size CSV file this code is working fine, but when I tried for larger size CSV files, Its shows an error. import os import g
Solution 1:
While using large files, it's better to use 'constant_memory' for controlled memory usage like:
workbook = Workbook(csvfile + '.xlsx', {'constant_memory': True}).
Ref: xlsxwriter.readthedocs.org/en/latest/working_with_memory.html
Solution 2:
I found Out New Code with panda package, this code is working fine now
import pandas
data = pandas.read_csv('Documents_2/AdvMedcsv.csv')
data = data.groupby(lambda x: data['research_id'][x]).first()
writer = pandas.ExcelWriter('Documents_2/AdvMed.xlsx',engine='xlsxwriter')data.to_excel(writer)
writer.save()
Post a Comment for "Convert Large Csv File To Excel Using Python 3"