Reading csv file
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Dec 17 00:36:54 EST 2013
On 17/12/2013 05:20, Igor Korot wrote:
> Hi, ALL,
> Is there a better way to do that:
>
> def Read_CSV_File(filename):
> file = open(filename, "r")
> reader = csv.DictReader(file)
> line = 1
> for row in reader:
> if line < 6:
> reader.next()
> line++
> # process the CSV
>
> Thank you.
>
Something like.
it = iter(csv.DictReader(file))
for _ in range(4): # if I've counted correctly :)
next(it)
for row in it:
# process the CSV
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list