I have a csv file contaning 30000000 entries. like this
കൃഷി 3
വ്യാപകമാകുന്നു 2
നെല്കൃഷി 2
വെള്ളം 2
നെല്ല് 2
മാത്രമേ 2
ജല 2
When I try to reverse the word order I am getting the following error
Traceback (most recent call last):
File "/home//grpus/dg.py", line 8, in <module>
writer.writerow((row[1], row[0]))
IndexError: list index out of range
This is the code:
import csv
with open('s.csv', 'rb') as f:
reader = csv.reader(f, delimiter='\t')
with open("revmal.txt", "w") as o:
writer = csv.writer(o, delimiter='\t')
for row in reader:
writer.writerow((row[1], row[0]))
Edit
writer.writerow(row[::-1])
When I try to fix it
How to fix this error?
Traceback (most recent call last):
File "/home/grpus/dg.py", line 7, in <module>
for row in reader:
Error: field larger than field limit (131072)
The file is 1.4 Gb in size
wc -L s.csv
936
{if(length($0)>max){max=length($0);maxline=$0}}END{print maxline} This produced
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������!� 1, 186 characters
writer.writerow(row[::-1])?wc -L s.csv?awk '{if(length($0)>max){max=length($0);maxline=$0}}END{print maxline}' s.csv? Is it a very long line?