Reading a CSV file

Dan Stromberg drsalists at gmail.com
Tue Apr 23 18:34:56 EDT 2013


On Tue, Apr 23, 2013 at 2:58 PM, Ana Dionísio <anadionisio257 at gmail.com>wrote:

> Thank you, but can you explain it a little better? I am just starting in
> python and I don't think I understood how to apply your awnser
> --
> http://mail.python.org/mailman/listinfo/python-list
>

#!/usr/local/pypy-1.9/bin/pypy

import csv

def main():
    with open('test.csv', 'r') as file_:
        for row in csv.reader(file_, delimiter="|"):
            print row

main()

# Example input:
# abc|def|ghi
# jkl|mno|pqr

In this way, you get one row at a time, instead of all rows at once.

HTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130423/39c7b958/attachment.html>


More information about the Python-list mailing list