how can i change the text delimiter

skip at pobox.com skip at pobox.com
Wed Aug 30 06:29:28 EDT 2006


    sonald> Can anybody tell me how to change the text delimiter in FastCSV
    sonald> Parser?  By default the text delimiter is double quotes(") I
    sonald> want to change it to anything else... say a pipe (|)..  can
    sonald> anyone please tell me how do i go about it?

I'm not familiar with a FastCSV module in Python.  Google suggests there is
a FastCsv module in Ruby.

Just in case what you are really referring to is the csv module in Python,
here's how you do it.  Suppose your CSV file looks like an Excel-generated
CSV file save for the weird quote character:

    import csv

    class PipeQuote(csv.excel):
        quotechar='|'

    ...

    reader = csv.reader(open("somefile", "rb"), dialect=PipeQuote)
    for row in reader:
        print row

Full documentation is here:

    http://docs.python.org/dev/lib/module-csv.html

Skip



More information about the Python-list mailing list