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

CSV: minimalquoting and skipinitialspace,

P: n/a

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
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

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

Jul 18 '05 #2

P: n/a
[Skip Montanaro <sk**@pobox.com>]
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
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.