Re: problems with CSV module

2010-06-05 Thread Tim Roberts
Carlos Grohmann wrote: > >Hi all, I'm using csv to read text files, and its working fine, except >in two cases: > >- when there is only one line of text (data) in the file >- when there is a blank line after the last data line >dialect = csv.Sniffer().sniff(sample) # Check for file format wit

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Carlos Grohmann wrote: >> Use: >> ? ?csvfile = csv.reader(csvfile, dialect=dialect) >> dialect is a keyword argument. > > thanks for pointing that out.it stopped the errors when there s > only one data line, but it still can't get the values for that > line Is it possible your data

Re: problems with CSV module

2010-06-03 Thread Carlos Grohmann
Thanks for your prompt response, Neil. > That data doesn't appear to be csv worthy. Why not use str.split > or str.partition? Well, I should have said that this is one kind of data. The function is part of a larger app, and there is the possibility that someone uses headers in the data files, or

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Neil Cerutti wrote: > Do you really need to use the Sniffer? You'll probably be better > off... ...defining your own dialect based on what you know to be the file format. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Carlos Grohmann wrote: > Hi all, I'm using csv to read text files, and its working fine, except > in two cases: > > - when there is only one line of text (data) in the file > - when there is a blank line after the last data line > > this is the kind of data: > > 45 67 89 > 23 45 06

problems with CSV module

2010-06-03 Thread Carlos Grohmann
Hi all, I'm using csv to read text files, and its working fine, except in two cases: - when there is only one line of text (data) in the file - when there is a blank line after the last data line this is the kind of data: 45 67 89 23 45 06 12 34 67 ... and this is the function: def getData(pa

Re: Problems with csv module

2005-05-14 Thread Tim Roberts
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > >does the CSV format even support Unicode-encoded data streams? Since there is no RFC or ISO standard for CSV, I'd say the answer was "yes". I just tried it with Excel, which is probably as close as we can get to the canonical csv application. It can

Re: Problems with csv module

2005-05-12 Thread John Machin
On Wed, 11 May 2005 23:52:56 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: >John Machin <[EMAIL PROTECTED]> writes: >> The CSV format is not defined at all, AFAIK. > >Just for the record, http://www.ietf.org/internet-drafts/draft-shafranovich-mime-csv-05.txt > " Bletch" ,"""Bletch""", "Ble

Re: Problems with csv module

2005-05-11 Thread Mike Meyer
John Machin <[EMAIL PROTECTED]> writes: > The CSV format is not defined at all, AFAIK. Just for the record, http://www.ietf.org/internet-drafts/draft-shafranovich-mime-csv-05.txt >. You'll also see application that deal with the application/csv MIME type. http://www.mire

Re: Problems with csv module

2005-05-11 Thread John Machin
On Wed, 11 May 2005 20:02:25 +0200, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Skip Montanaro wrote: > >> Fredrik> does the CSV format even support Unicode-encoded data streams? >> >> Based on the requests I've seen here and on the [EMAIL PROTECTED] mailing >> list, >> it appears people are

Re: Problems with csv module

2005-05-11 Thread John Machin
On Wed, 11 May 2005 14:08:08 -0500, Skip Montanaro <[EMAIL PROTECTED]> wrote: > >>> Based on the requests I've seen here and on the [EMAIL PROTECTED] > mailing >>> list, it appears people are certainly generating CSV files which >>> contain Unicode- encoded data. > >Fredrik> in wh

Re: Problems with csv module

2005-05-11 Thread Skip Montanaro
>> Based on the requests I've seen here and on the [EMAIL PROTECTED] mailing >> list, it appears people are certainly generating CSV files which >> contain Unicode- encoded data. Fredrik> in what encodings? I've seen hints about iso-8859-1/iso-8859-15 and mention that Excel 2000

Re: Problems with csv module

2005-05-11 Thread Fredrik Lundh
Skip Montanaro wrote: > Fredrik> does the CSV format even support Unicode-encoded data streams? > > Based on the requests I've seen here and on the [EMAIL PROTECTED] mailing > list, > it appears people are certainly generating CSV files which contain Unicode- > encoded data. in what encoding

Re: Problems with csv module

2005-05-11 Thread Skip Montanaro
Fredrik> does the CSV format even support Unicode-encoded data streams? Based on the requests I've seen here and on the [EMAIL PROTECTED] mailing list, it appears people are certainly generating CSV files which contain Unicode-encoded data. Skip -- http://mail.python.org/mailman/listinfo/py

Re: Problems with csv module

2005-05-11 Thread Fredrik Lundh
Richie Hindle wrote: > [Florian] > > You mean that csv.reader can't work with unicode as the delimiter parameter? > > Exactly. http://www.python.org/doc/2.3.5/lib/module-csv.html says: > > "Note: This version of the csv module doesn't support Unicode input. Also, > there are currently some issues

Re: Problems with csv module

2005-05-11 Thread Skip Montanaro
>> You mean that csv.reader can't work with unicode as the delimiter >> parameter? Richie> Exactly Richie> "Note: This version of the csv module doesn't support Unicode Richie> input Richie> That note is still there in the current development docs, so it Rich

Re: Problems with csv module

2005-05-11 Thread Richie Hindle
[Florian] > How can I convert Unicode to ASCII? You're writing code using Unicode and you don't know how to convert it ASCII? You need to do some reading. Here are a few links - Google can provide many more: http://docs.python.org/tut/node5.html#SECTION00513 http://diveinto

Re: Problems with csv module

2005-05-11 Thread Florian Lindner
Richie Hindle wrote: > > [Florian] >> You mean that csv.reader can't work with unicode as the delimiter >> parameter? > > Exactly. http://www.python.org/doc/2.3.5/lib/module-csv.html says: > > "Note: This version of the csv module doesn't support Unicode input. Also, > there are currently some

Re: Problems with csv module

2005-05-11 Thread Richie Hindle
[Florian] > You mean that csv.reader can't work with unicode as the delimiter parameter? Exactly. http://www.python.org/doc/2.3.5/lib/module-csv.html says: "Note: This version of the csv module doesn't support Unicode input. Also, there are currently some issues regarding ASCII NUL characters.

Re: Problems with csv module

2005-05-11 Thread Florian Lindner
Richie Hindle wrote: > > [Florian] >> I've one problem using the csv module. >> The code: >> >> self.reader = csv.reader(f, delimiter = ",") >> >> works perfectly. But when I use a variable for delimiter: >> >> self.reader = csv.reader(f, delimiter = Adelimiter) >> >> I get th

Re: Problems with csv module

2005-05-11 Thread Richie Hindle
[Florian] > I've one problem using the csv module. > The code: > > self.reader = csv.reader(f, delimiter = ",") > > works perfectly. But when I use a variable for delimiter: > > self.reader = csv.reader(f, delimiter = Adelimiter) > > I get the traceback: > > > File "/home/fl

Problems with csv module

2005-05-11 Thread Florian Lindner
Hello, I've one problem using the csv module. The code: self.reader = csv.reader(f, delimiter = ",") works perfectly. But when I use a variable for delimiter: self.reader = csv.reader(f, delimiter = Adelimiter) I get the traceback: File "/home/florian/visualizer/ConfigReader.