Question: I'm new to Python and I'm wanting to print only the first 10 lines of a huge csv file. 

Here's my code so far that prints all of the lines in the csv file

```
import csv
with open('titanic.csv') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        print(row['survived'], row['pclass'], row['name'], row['sex'], row['age'])

```

Answer: 
You could just `break` after 10 lines.

```
import csv
with open('titanic.csv') as csvfile:
    reader = csv.DictReader(csvfile)
    for i,row in enumerate(reader):
        print(row['survived'], row['pclass'], row['name'], row['sex'], row['age'])
        if(i >= 9):
            break

```
Adrien El Zein's answer is enough for your question. However, if you think it's slightly confusing (I don't think so):

```
import csv
counter = 0

with open('titanic.csv') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in enumerate(reader):
       print(row['survived'], row['pclass'], row['name'], row['sex'], row['age'])
       counter += 1
       if counter >= 9:
           break

```

All I did was rename the variable `i` to `counter`. Also, for an alternative loop:

```
import csv
counter = 0

with open('titanic.csv') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in enumerate(reader):
       print(row['survived'], row['pclass'], row['name'], row['sex'], row['age'])
       while counter < 10:
           counter += 1
       else:
           break

```

I tried and tested the `while-else` loop using Python 3.4.3 (not sure which version you have) and can tell you that it works properly.