>Any idea why it might throw an exception on encountering a NULL in the
>input stream? It accepts all other 255 byte values. Was this behaviour
>intended? Perhaps a comment should be added to the docs.
>Thanks for your work on the module anyway.
The original module was like this - it comes about
On 07/03/2018 07:59, Andrew McNamara wrote:
Last time I read the documentation, it was recommended that
the file be opened in BINARY mode ("rb").
It recommends binary mode, but seems to largely work fine with
text/ascii mode or even arbitrary iterables. I've not seen the
rationale behin
>> Last time I read the documentation, it was recommended that
>> the file be opened in BINARY mode ("rb").
>
>It recommends binary mode, but seems to largely work fine with
>text/ascii mode or even arbitrary iterables. I've not seen the
>rationale behind the binary recommendation, but in 10+
On 2018-03-01 23:57, John Pote wrote:
> On 01/03/2018 01:35, Tim Chase wrote:
> > While inelegant, I've "solved" this with a wrapper/generator
> >
> >f = file(fname, …)
> >g = (line.replace('\0', '') for line in f)
> I wondered about something like this but thought if there's a way
> of a
On 01/03/2018 01:35, Tim Chase wrote:
While inelegant, I've "solved" this with a wrapper/generator
f = file(fname, …)
g = (line.replace('\0', '') for line in f)
I wondered about something like this but thought if there's a way of
avoiding the extra step it would keep the execution speed u
On 01/03/2018 02:38, Dennis Lee Bieber wrote:
On Wed, 28 Feb 2018 23:40:41 +, John Pote
declaimed the following:
with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile:
Pardon? Has the CSV module changed in the last year or so?
Python 3.6 docs say csv reader has to be gi
On 2018-03-01, Tim Chase wrote:
> On 2018-02-28 21:38, Dennis Lee Bieber wrote:
>> > with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile:
>>
>> Pardon? Has the CSV module changed in the last year or so?
>>
>> Last time I read the documentation, it was recommended that
>> t
On 2/28/2018 8:35 PM, Tim Chase wrote:
While inelegant, I've "solved" this with a wrapper/generator
f = file(fname, …)
g = (line.replace('\0', '') for line in f)
reader = csv.reader(g, …)
for row in reader:
process(row)
I think this is elegant in that is cleans the input strea
On 2018-02-28 21:38, Dennis Lee Bieber wrote:
> > with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile:
>
> Pardon? Has the CSV module changed in the last year or so?
>
> Last time I read the documentation, it was recommended that
> the file be opened in BINARY mode ("rb")
While inelegant, I've "solved" this with a wrapper/generator
f = file(fname, …)
g = (line.replace('\0', '') for line in f)
reader = csv.reader(g, …)
for row in reader:
process(row)
My actual use at $DAYJOB cleans out a few other things
too, particularly non-breaking spaces coming from
On Aug 25, 8:49 am, Peter Otten <__pete...@web.de> wrote:
> JKPeck wrote:
> > On Aug 24, 10:43 pm, John Yeung wrote:
> >> On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote:
>
> >> > If I understand you correctly the csv.writer already does
> >> > what you want:
>
> >> > >>> w.writerow([1,No
JKPeck wrote:
> On Aug 24, 10:43 pm, John Yeung wrote:
>> On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote:
>>
>> > If I understand you correctly the csv.writer already does
>> > what you want:
>>
>> > >>> w.writerow([1,None,2])
>> > 1,,2
>>
>> > just sequential commas, but that is the sp
On Aug 24, 10:43 pm, John Yeung wrote:
> On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote:
>
> > If I understand you correctly the csv.writer already does
> > what you want:
>
> > >>> w.writerow([1,None,2])
> > 1,,2
>
> > just sequential commas, but that is the special treatment.
> > Witho
On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote:
> If I understand you correctly the csv.writer already does
> what you want:
>
> >>> w.writerow([1,None,2])
> 1,,2
>
> just sequential commas, but that is the special treatment.
> Without it the None value would be converted to a string
> an
On Aug 24, 1:30 pm, JKPeck wrote:
> I'm trying to get the csv module (Python 2.6) to write data
> records like Excel. The excel dialect isn't doing it. The
> problem is in writing None values. I want them to result
> in just sequential commas - ,, but csv treats None specially,
> as the doc say
JKPeck wrote:
> I'm trying to get the csv module (Python 2.6) to write data records
> like Excel. The excel dialect isn't doing it. The problem is in
> writing None values. I want them to result in just sequential commas
> - ,, but csv treats None specially, as the doc says,
>
> "To make it as
On Aug 24, 11:30 am, JKPeck wrote:
> I'm trying to get the csv module (Python 2.6) to write data records
> like Excel. The excel dialect isn't doing it. The problem is in
> writing None values. I want them to result in just sequential commas
> - ,, but csv treats None specially, as the doc says
7stud wrote:
> On Feb 17, 9:11 pm, 7stud <[EMAIL PROTECTED]> wrote:
>> On Feb 17, 7:09 pm, Christopher Barrington-Leigh
>>
>>
>>
>> <[EMAIL PROTECTED]> wrote:
>>> Here is a file "test.csv"
>>> number,name,description,value
>>> 1,"wer","tape 2"",5
>>> 1,vvv,"hoohaa",2
>>> I want to convert it to tab
On Feb 17, 9:11 pm, 7stud <[EMAIL PROTECTED]> wrote:
> On Feb 17, 7:09 pm, Christopher Barrington-Leigh
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > Here is a file "test.csv"
> > number,name,description,value
> > 1,"wer","tape 2"",5
> > 1,vvv,"hoohaa",2
>
> > I want to convert it to tab-separated without
On Feb 17, 7:09 pm, Christopher Barrington-Leigh
<[EMAIL PROTECTED]> wrote:
> Here is a file "test.csv"
> number,name,description,value
> 1,"wer","tape 2"",5
> 1,vvv,"hoohaa",2
>
> I want to convert it to tab-separated without those silly quotes. Note
> in the second line that a field is 'tape 2"'
On Feb 17, 8:09 pm, Christopher Barrington-Leigh
<[EMAIL PROTECTED]> wrote:
> Here is a file "test.csv"
> number,name,description,value
> 1,"wer","tape 2"",5
> 1,vvv,"hoohaa",2
>
> I want to convert it to tab-separated without those silly quotes. Note
> in the second line that a field is 'tape 2"'
>Here is a file "test.csv"
>number,name,description,value
>1,"wer","tape 2"",5
>1,vvv,"hoohaa",2
>
>I want to convert it to tab-separated without those silly quotes. Note
>in the second line that a field is 'tape 2"' , ie two inches: there is
>a double quote in the string.
The input format is ambi
Wow; I guess this is a REAL problem! I would have thought that something as
common as Unicode CSV would have been supported by SOMEONE.
On 10/5/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> According to the Python 2.5 documentation, Unicode is not supported
> through the CSV module. Is
On Aug 25, 12:29 am, luca72 <[EMAIL PROTECTED]> wrote:
> Hello at all i have a problem with the csv module, really i don't
> undestud the writerows:
>
> if i have to write only one row i do as follow:
> def scrivo_csv(self):
> import csv
> q_righe = self.tableWidget.rowCount()
>
Jon Clements a écrit :
> Hi Group,
>
> If I have a CSV reader that's passed to a function, is it possible for
> that function to retrieve a reference to the "fileobj" like object
> that was passed to the reader's __init__? For instance, if it's using
> an actual file object, then depending on the
Jon> If I have a CSV reader that's passed to a function, is it possible
Jon> for that function to retrieve a reference to the "fileobj" like
Jon> object that was passed to the reader's __init__?
Nope, that isn't exposed from the C type.
Skip
--
http://mail.python.org/mailman/listin
Fredrik Lundh wrote:
> if you're wrapping some cmd.exe command in an internal API, it's usually
> easier to call "os.path.normpath" the last thing you do before you call
> "os.system", than to get all the backslashes right in your code.
>
> also see:
>
> http://www.effbot.org/pyfaq/why-can-t-r
John Machin wrote:
> Not all APIs do the right thing. If you fire up the cmd.exe shell and
> feed it slashes as path separators, it barfs. Example:
> C:\junk>dir c:/junk/*.bar
> Invalid switch - "junk".
> Hence the advice to use rawstrings with backslashes -- they work under
> all circumst
On 2/11/2006 2:38 PM, [EMAIL PROTECTED] wrote:
> >> ...alternatively you can just use 'unix slashes', e.g.
> >> 'c:/temp/book1.csv', since those work just fine 'cause the Windows
> >> APIs deal with them properly.
>
> John> Not all APIs do the right thing. If you fire up the cmd.ex
John Machin wrote:
> Tom Plunket wrote:
>
>>John Machin wrote:
>>
>>
>>>If you were to write 'c:\temp\book1.csv', it would blow up ... because
>>>\t -> tab and \b -> backspace. Get into the habit of *always* using raw
>>>strings r'C:\Temp\Book1.csv' for Windows file names (and re patterns).
>>>You
>> ...alternatively you can just use 'unix slashes', e.g.
>> 'c:/temp/book1.csv', since those work just fine 'cause the Windows
>> APIs deal with them properly.
John> Not all APIs do the right thing. If you fire up the cmd.exe shell
John> and feed it slashes as path separators
Tom Plunket wrote:
> John Machin wrote:
>
> > If you were to write 'c:\temp\book1.csv', it would blow up ... because
> > \t -> tab and \b -> backspace. Get into the habit of *always* using raw
> > strings r'C:\Temp\Book1.csv' for Windows file names (and re patterns).
> > You could use double backs
John Machin wrote:
> If you were to write 'c:\temp\book1.csv', it would blow up ... because
> \t -> tab and \b -> backspace. Get into the habit of *always* using raw
> strings r'C:\Temp\Book1.csv' for Windows file names (and re patterns).
> You could use double backslashing 'C:\\Temp\\Book1.csv' b
Jeff Blaine wrote:
> It's been a year or so since I written Python code, so maybe
> I am just doing something really dumb, but...
>
> Documentation
> =
>
> class DictReader(csvfile[,fieldnames=None,
> [,restkey=None[, restval=None[, dialect='excel'
> [,
I see what's wrong. Me. Wow am I ever rusty.
Jeff Blaine wrote:
> It's been a year or so since I written Python code, so maybe
> I am just doing something really dumb, but...
>
> Documentation
> =
>
> class DictReader(csvfile[,fieldnames=None,
> [,restkey=None[, re
Jeff Blaine wrote:
> It's been a year or so since I written Python code, so maybe
> I am just doing something really dumb, but...
>
> Documentation
> =
>
> class DictReader(csvfile[,fieldnames=None,
> [,restkey=None[, restval=None[, dialect='excel'
>
John Machin wrote:
> tobiah wrote:
>>>
>>>
>> I agree with Henryk's evaluation
>
> Henryk?? Have I missed a message in the thread, or has the effbot
> metamorphosed into the aitchbot?
>
How strange. Either my client was whacked, or I was. I was
actually referring to your "baroque byzantine ov
tobiah wrote:
> >
> >
> >
>
> I agree with Henryk's evaluation
Henryk?? Have I missed a message in the thread, or has the effbot
metamorphosed into the aitchbot?
--
http://mail.python.org/mailman/listinfo/python-list
>> The docs clearly state what the defaults are, but they are not
>> in the code. It seems so clumsy to have to specify every one of
>> these, just to change the delimiter from comma to tab.
>>
>> http://docs.python.org/lib/csv-fmt-params.html :
>
> The "it defaults to" clauses should probably
tobiah wrote:
>> you may be misreading the docs; the Dialect has no values at all, and
>> must be subclassed (and the subclass must provide settings).
>
> The docs clearly state what the defaults are, but they are not
> in the code. It seems so clumsy to have to specify every one
> of these,
tobiah wrote:
> > However, more generally, the docs also clearly state that "In addition
> > to, or instead of, the dialect parameter, the programmer can also
> > specify individual formatting parameters, which have the same names as
> > the attributes defined below for the Dialect class."
>
> I d
> However, more generally, the docs also clearly state that "In addition
> to, or instead of, the dialect parameter, the programmer can also
> specify individual formatting parameters, which have the same names as
> the attributes defined below for the Dialect class."
I definitely missed that. Kn
tobiah wrote:
>
> The docs clearly state what the defaults are, but they are not
> in the code. It seems so clumsy to have to specify every one
> of these, just to change the delimiter from comma to tab.
>
That particular case is handled by the built-in (but cunningly
concealed) 'excel-tab' clas
for row in csv.reader(instream, delimiter="\t"):
Awesome. Thanks.
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
tobiah wrote:
>> you may be misreading the docs; the Dialect has no values at all, and
>> must be subclassed (and the subclass must provide settings).
>
> The docs clearly state what the defaults are, but they are not
> in the code. It seems so clumsy to have to specify every one
> of these, jus
tobiah> So now it works, but it is still strange about the absent
tobiah> defaults.
The csv.Dialect class is essentially pure abstract. Most of the time I
subclass csv.excel and just change the one or two things I need.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
> you may be misreading the docs; the Dialect has no values at all, and
> must be subclassed (and the subclass must provide settings).
The docs clearly state what the defaults are, but they are not
in the code. It seems so clumsy to have to specify every one
of these, just to change the delim
>
> That's possible but why didn't you follow the way `csv.Dialect` set the
> class attributes?
>
> class MyDialect(csv.Dialect):
> delimiter = '\t'
> lineterminator = '\n'
> # and so on…
Because I'm hung over.
--
Posted via a free Usenet account from http://www.teranews.com
--
tobiah wrote:
> The docs are a little terse, but I gather that I am supposed
> to subclass cvs.Dialect:
>
> class dialect(csv.Dialect):
> pass
>
> Now, the docs say that all of the attributes have reasonable
> defaults, but instantiating the above gives:
you may be misreading the docs;
In <[EMAIL PROTECTED]>, tobiah wrote:
> I'm trying to create a cvs.reader object using a custom dialect.
>
> The docs are a little terse, but I gather that I am supposed
> to subclass cvs.Dialect:
>
> class dialect(csv.Dialect):
> pass
>
> Now, the docs say that all of the attributes ha
Ok, I'm an idiot. I didn't even pass my dialect
object to the reader() call.
So now it works, but it is still strange about
the absent defaults.
Tobiah
> This runs, but the delimiter is still the comma.
> When list.csv is comma delim, it works correctly,
> but when list.csv has tab separated v
Thanks a lot Skip. Sure that this will help.
Learned two things: how to do it and to look at the docs for 2.5 also.
These samples are not in the 2.4.2 reference guide.
RudyOn 2/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Rudy> I'm having problems writing unicode to a csv file.Rud
Rudy> I'm having problems writing unicode to a csv file.
Rudy> I use the following code:
...
Have you tried the example UnicodeReader and UnicodeWriter classes in the
module documentation:
http://www.python.org/dev/doc/devel/lib/node631.html
While the csv module is 8-bit clean i
Forgot to mention that I work on Windows XP and Windows 2003.On 2/23/06, Rudy Schockaert <[EMAIL PROTECTED]
> wrote:I'm having problems writing unicode to a csv file.I use the following code:
-import codecsimport csvcsvfile = csv.writer(codecs.open('filename.csv','w+','utf-8
Laurent> If I change:
Laurent> freq = line.strip().count(char)
Laurent> by:
Laurent> freq = line.count(char)
Laurent> It works fine.
Laurent> Do you have a workaround for that?
Nope. I just checked in precisely your fix to the Python repository.
Skip
--
http://mai
In fact, there is another bug:
In my CVS file, all the records ends with a trailing tab '\t'
except the header because the last field is always empty.
For example, I get :
>>> import csv
>>> t_sniffer = csv.Sniffer()
>>> t_data = "aaa\tbbb\r\nAAA\t\r\nBBB\t\r\n"
>>> t_dialect = t_sniffer.sniff(t_
Sorry,
Here is my example:
Python 2.3.1 (#1, Sep 29 2003, 15:42:58)
[GCC 2.96 2731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> t_sniffer = csv.Sniffer()
>>> t_data = "aaa\tbbb\r\n\r\nAAA\tBBB\r\n"
>>> t_diale
me> Using a file with the following contents:
me> >>> open("tabber.csv", "rb").read()
me> '1\t2\tabc\n3\t4\tdef\n'
me> I get:
me> >>> sniffer = csv.Sniffer()
me> >>> d = sniffer.sniff(open("tabber.csv", "rb").read())
me> >>> d.delimiter
me>
Laurent> To read my CSV file, I choose to 'sniff' with a sample data in
Laurent> order to get the dialect. The problem I meet is that I get a
Laurent> wrong dialect: the sniffer return an empty string delimiter. It
Laurent> is probably a bug in _guess_delimiter() method.
Laur
Laurent Laporte wrote:
> I'm using cvs standard module under Python 2.3 / 2.4 to write a file
> delimited with tabs. I use the "excel-tab" dialect to do that.
>
> To read my CSV file, I choose to 'sniff' with a sample data in order to
> get the dialect.
> The problem I meet is that I get a wrong d
Many thanks Andrew for this excellent piece of knowledge :-). 4
characters of code and everything is great!
Regards,
David
On Friday, October 14, 2005, at 12:11 AM, Andrew McNamara wrote:
>> Hi. I have had good success with CSV module but recently came across
>> problem with reading excel from
>Hi. I have had good success with CSV module but recently came across
>problem with reading excel from Mac Office. The trouble is with line
>endings. Instead of \r\n you have just \r and the file as a whole
>appears as a single line. CSV coughs and provides this exception:
>
>_csv.Error: newli
Chris wrote:
> hi,
> thanks for all replies, I try if I can at least get the work done.
>
> I guess my problem mainly was the rather mindflexing (at least for
me)
> coding/decoding of strings...
>
> But I guess it would be really helpful to put the
UnicodeReader/Writer
> in the docs
UNFORTUNATELY
hi,
thanks for all replies, I try if I can at least get the work done.
I guess my problem mainly was the rather mindflexing (at least for me)
coding/decoding of strings...
But I guess it would be really helpful to put the UnicodeReader/Writer
in the docs
thanks a lot
chris
--
http://mail.python
Chris wrote:
> hi,
> to convert excel files via csv to xml or whatever I frequently use
the
> csv module which is really nice for quick scripts. problem are of
course
> non ascii characters like german umlauts, EURO currency symbol etc.
The umlauted characters should not be a problem, they're all
Chris wrote:
the current csv module cannot handle unicode the docs say, is there any
workaround or is unicode support planned for the near future? in most
cases support for characters in iso-8859-1(5) would be ok for my
purposes but of course full unicode support would be great...
It doesn't sup
Chris> the current csv module cannot handle unicode the docs say, is
Chris> there any workaround or is unicode support planned for the near
Chris> future?
Skip> True, it can't.
Hmmm... I think the following should be a reasonable workaround in most
situations:
#!/usr/bin/en
Chris> the current csv module cannot handle unicode the docs say, is
Chris> there any workaround or is unicode support planned for the near
Chris> future?
True, it can't.
Chris> obviously I am not a python pro, i did not even find the py
Chris> source for the module, it seeme
ok thanks
it works
S.
"Kent Johnson" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> simon.alexandre wrote:
> > Hi all,
> >
> > I use csv module included in python 2.3. I use the writer and encouter
the
> > following problem: in my output file (.csv) there is a duplicatio
simon.alexandre wrote:
Hi all,
I use csv module included in python 2.3. I use the writer and encouter the
following problem: in my output file (.csv) there is a duplication of the
end of line character, so when I open the csv file in Ms-Excel a blank line
is inserted between each data line.
From th
simon.alexandre wrote:
> I use csv module included in python 2.3. I use the writer and encouter the
> following problem: in my output file (.csv) there is a duplication of the
> end of line character, so when I open the csv file in Ms-Excel a blank
> line is inserted between each data line.
>
> O
71 matches
Mail list logo