Python Forum
Reading Specific Rows In a CSV File - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Reading Specific Rows In a CSV File (/thread-38948.html)



Reading Specific Rows In a CSV File - finndude - Dec-13-2022

Hi,

I have a CSV file which I have attached a link to a photo of it to look at. I want to be able to retrieve the data from specific rows, based on the value in the first column, almost like SQL. So, I want to retrieve all the data from the rows, where the user_id (first column) = 2 and nothing else. How can I do this?

Thanks.


Click for Image





https://freeimage.host/i/HoxIhTQ


RE: Reading Specific Rows In a CSV File - deanhystad - Dec-13-2022

I would use pandas.read_ csv().


RE: Reading Specific Rows In a CSV File - perfringo - Dec-13-2022

If you write code then you probably have text editor/IDE. If you have csv file then you probably open it with said text editor/IDE. So please use copy-paste instead of posting images (how to use BBCode to enhance your posts BBCode help).

I also suggest to get acquainted with topic of Homework and No Effort questions


RE: Reading Specific Rows In a CSV File - finndude - Dec-13-2022

It’s fine now, I have opted to use sqlite to make a database rather than a csv file. Thanks for the information