I have a CSV file with 100 rows.
How do I read specific rows?
I want to read say the 9th line or the 23rd line etc?
You could use a list comprehension to filter the file like so:
list comprehension
with open('file.csv') as fd: reader=csv.reader(fd) interestingrows=[row for idx, row in enumerate(reader) if idx in (28,62)] # now interestingrows contains the 28th and the 62th row after the header
1.4m articles
1.4m replys
5 comments
57.0k users