I have a csv file containing 60,000 entries. I read them and saved them in a nested list:
entries = [] with open('mnist_train.csv', 'r') as f: mycsv = csv.reader(f) for row in mycsv: entries.append(row)
Instead of reading all 60,000, how would I read only the first thousand records?
I tried this without success:
entries = [] with open('mnist_train.csv', 'r') as f: mycsv = csv.reader(f) for row in mycsv[:1000]: entries.append(row)
source share