Python Forum

Full Version: Reading Specific Rows In a CSV File
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
I would use pandas.read_ csv().
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
It’s fine now, I have opted to use sqlite to make a database rather than a csv file. Thanks for the information