Python Forum
Reading Specific Rows In a CSV File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading Specific Rows In a CSV File
#1
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
"Only Boring People Get Bored"
Reply
#2
I would use pandas.read_ csv().
Reply
#3
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
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#4
It’s fine now, I have opted to use sqlite to make a database rather than a csv file. Thanks for the information
"Only Boring People Get Bored"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting specific file from an archive tester_V 4 522 Jan-29-2024, 06:41 PM
Last Post: tester_V
Sad problems with reading csv file. MassiJames 3 652 Nov-16-2023, 03:41 PM
Last Post: snippsat
  Reading a file name fron a folder on my desktop Fiona 4 927 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,114 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,520 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  Reading a file JonWayn 3 1,107 Dec-30-2022, 10:18 AM
Last Post: ibreeden
  Excel file reading problem max70990 1 901 Dec-11-2022, 07:00 PM
Last Post: deanhystad
  Replace columns indexes reading a XSLX file Larry1888 2 996 Nov-18-2022, 10:16 PM
Last Post: Pedroski55
  reading content between a specific xml tag saisankalpj 1 851 Oct-31-2022, 01:37 PM
Last Post: wavic
  Failing reading a file and cannot exit it... tester_V 8 1,838 Aug-19-2022, 10:27 PM
Last Post: tester_V

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020