i have a xlsx file which has 500,000 rows.I want to copy it into a csv file, but I am only able to copy 65k rows and then the program ends.here is my code i am using for copying data from xlsx file to csv file.amd it is taking too much time to even print 65k lines.
import openpyxl
import csv
import time
import collections
def csv_from_excel() :
t1=(time.time())*1000
workbook = openpyxl.load_workbook(filename = '5lac_xlsx.xlsx',optimized_read = True, use_iterators = True)
sh=workbook.get_sheet_by_name('Sheet1')
your_csv_file = open('your_csv_file.csv','wb')
wr = csv.writer(your_csv_file,quoting=csv.QUOTE_ALL)
t2=(time.time())*1000
print (t2-t1)
fp = open('your_csv_file.csv', 'wb')
a = csv.writer(fp, delimiter=',')
m1=(time.time())*1000
count=0
for row_t in sh.iter_rows():
for cell in row_t :
try :
count=count+1
wr.writerow([cell[3]])
#wr.writerow('\n')
except :
print "error"
print "count"
print count
your_csv_file.close()
m2=(time.time())*1000
print (m2-m1)
csv_from_excel()