Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > CSV: minimalquoting and skipinitialspace,

Reply
Thread Tools

CSV: minimalquoting and skipinitialspace,

 
 
Martin Bless
Guest
Posts: n/a
 
      05-19-2004

Currently QUOTE_MINIMAL in the standard module CSV only reacts to
"delimiter" and "quotechar". From the documentation:

Currently:
"""
QUOTE_MINIMAL
Instructs writer objects to only quote those fields which contain the
current delimiter or begin with the current quotechar.
"""

In my opinion there should be a way to turn on quoting as well for
those fields, that start with white space characters if the dialect
specifies

dialect.skipinitialspace = False

I wouldn't mind a change leading to this variant:

Proposal:
"""
QUOTE_MINIMAL
Instructs writer objects to only quote those fields which contain the
current delimiter or begin with the current quotechar or start
with a [blank | white space character] if the dialect specifies
skipinitialspace=False.
"""

What do you think?

MB - Martin Bless
 
Reply With Quote
 
 
 
 
Skip Montanaro
Guest
Posts: n/a
 
      05-19-2004

Martin> Proposal:

Martin> QUOTE_MINIMAL
Martin> Instructs writer objects to only quote those fields which
Martin> contain the current delimiter or begin with the current
Martin> quotechar or start with a [blank | white space character] if the
Martin> dialect specifies skipinitialspace=False.

Martin> What do you think?

It's an idea with merit. Can you post a feature request to the Python
project on SF? Even better would be a patch that implements the idea.

Skip

 
Reply With Quote
 
 
 
 
Martin Bless
Guest
Posts: n/a
 
      05-19-2004
[Skip Montanaro <>]

>Can you post a feature request to the Python
>project on SF?


Ok, I think I can do that. Having thought it over I'd love to see this
logic:

# pseudo code, untested
if dialect.quoteminimal:
quote_the_field = False
if dialect.delimiter in field:
quote_the_field = True
elif dialect.separator in field:
quote_the_field = True

# NEW: do quoting if field starts OR ends with a space or a tab
elif field[:1] in " \t" or field[-1:] in " \t":
quote_the_field = True


>Even better would be a patch that implements the idea.


Too bad, I can't. I had a look at it: the crucial parts are in the
c-code. That's too far for me in the moment ...

MB - Martin Bless
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments