How to read 2+gb csv file on python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to read 2+gb csv file on python?

Looking to read,write a 2+gb csv file on python.

19th Mar 2022, 10:34 PM
Kinjal Patel
4 Answers
+ 5
Hello, Kinjal Patel!! I'm with Simon Sauter, but if you want an example then here it is https://code.sololearn.com/c6r4tVNqNlvD/?ref=app for more or extra information you can go and check the offical documentation of pandas Happy Learning!
20th Mar 2022, 3:45 AM
Abhiyantā
Abhiyantā - avatar
+ 6
You can use the pandas.read_csv() method with the chunksize argument.
19th Mar 2022, 11:09 PM
Simon Sauter
Simon Sauter - avatar
+ 3
You can import the csv module. Then use it to read line by line or in chunks.Don't read in an entire file of that size into a variable as memory will be an issue. import csv
20th Mar 2022, 4:36 AM
Paul K Sadler
Paul K Sadler - avatar
+ 3
Kinjal Patel , what kind of operations are you trying to perform after reading the data. do you need to: - filter - modify / update - sort - delete (data, columns, rows) - insert (data, columns, rows) ... of the data?
20th Mar 2022, 10:50 AM
Lothar
Lothar - avatar