473,385 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reading a delimited text file

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
1 2200
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

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

Similar topics

14
by: Job Lot | last post by:
I have tab delimited text file which gets populated on daily basis via automated process. New entry is written at the bottom. I need to create a utility which makes a copy of this file with 10 most...
2
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
3
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files...
5
by: Christine | last post by:
I have code right now that reads in the file into an arraylist, but it reads in each line of the text file as a single element rather than the separate tab delimited strings in the line. Is there...
1
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
8
by: stephane8 | last post by:
I'm able to open and read my .csv file. But when the character "-" is in one of my fields (ex : 18802-002) I get a system.DBNull value ! Even if I edit the file with notepad and put "18802-002" I...
6
by: =?Utf-8?B?UmljaA==?= | last post by:
'--this code works but only reads text into one column when contains multiple cols Dim ds1x As New DataSet Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data...
1
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like...
2
by: tshad | last post by:
I have a program that is reading a csv file into a dataset. I want it to read the 1st line as data. But it ignores it. I have the Connection set up as: OleDbConnection csvConnection = new...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.