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?
Use list to grab all the rows at once as a list. Then access your target rows by their index/offset in the list. For example:
list
#!/usr/bin/env python import csv with open('source.csv') as csv_file: csv_reader = csv.reader(csv_file) rows = list(csv_reader) print(rows[8]) print(rows[22])