By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

Reading a delimited text file

P: 2
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
Mar 25 '08 #1
Share this Question
Share on Google+
1 Reply


Subsciber123
P: 87
Here is a place to start. See if you can get anything working from here:
Expand|Select|Wrap|Line Numbers
  1. import csv
Yes, there is a module for reading and writing csv files. You can choose the delimiter in there.
Apr 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.