Reading csv file
Krishnan Shankar
i.am.songoku at gmail.com
Tue Dec 17 00:29:44 EST 2013
Hi Igor
You can use the following way to do this using "with" operator.
def Read_CSV_File(filename):
with open(filename, "r") as csvfile:
csvreader = csv.DictReader(csvfile)
line = 1
for row in csvreader:
if line < 6:
reader.next()
line++
continue
# process the CSV
Rest of the things are pretty much straightforward.
Regards,
Krishnan
On Tue, Dec 17, 2013 at 10:50 AM, Igor Korot <ikorot01 at gmail.com> 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.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131217/f2157eac/attachment.html>
More information about the Python-list
mailing list