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 <[email protected]> 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
>
--
https://mail.python.org/mailman/listinfo/python-list