Reading a delimited text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yesvee
    New Member
    • Mar 2008
    • 2

    Reading a delimited text file

    Hello All,

    I'm new for Python programming and I'm having some issues parsing a delimited text file. Any help, suggestions and advice is really appreciated. Thanks a lot in advance.

    Objective

    My input file could be .txt or .dat or .csv
    Any kind of delimited file with the following delimiters (',','/','|',';',':')
    1. Make sure the files have a header
    2. File can have only 1, 2 or 6 columns. Any other number of columns makes it an invalid file
    3. Some column entries will have , in it. It should not clash with delimiter when the delimiter used is a ,
    .

    I want to use use sniff() to return the Dialect. How do I retrive the columns using CSV and make sure it has header and not just direct data.

    regards
    YesVee
  • Subsciber123
    New Member
    • Nov 2006
    • 87

    #2
    Here is a place to start. See if you can get anything working from here:
    [code=python]import csv[/code]
    Yes, there is a module for reading and writing csv files. You can choose the delimiter in there.

    Comment

    Working...