Skip Menu |

This queue is for tickets about the Text-CSV_XS CPAN distribution.

Report information
The Basics
Id: 50911
Status: resolved
Priority: 0/
Queue: Text-CSV_XS

People
Owner: Nobody in particular
Requestors: YKAR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.23
Fixed in: 0.70



Subject: Quoting of strings containing space character
Currently CSV entry is quoted if it contain space character. It would be nice to quote value only if it contains either leading or trailing spaces. I guess unquoted CSV entry with inner spaces is correct and can be parsed unambiguously. RATIONALE: - Generated CSV can be smaller on some datasets - Some broken programs does not support CSV quoting. If module quote strings only if really needed, generated output can be fed into such broken programs.
Thank you for taking into account my suggestion. quote_space, works not very well. If string has any leading or trailing spaces, they will be lost, because CSV parser strip any white space from the beginning and from the end of the string. So it is safe not to quote string only if string does not have leading or trailing spaces.
Subject: Re: [rt.cpan.org #50911] Quoting of strings containing space character
Date: Sun, 13 Dec 2009 13:30:22 +0100
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Sun, 13 Dec 2009 07:10:31 -0500, "YKAR via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> Queue: Text-CSV_XS > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50911 > > > Thank you for taking into account my suggestion. > > quote_space, works not very well. If string has any leading or trailing > spaces, they will be lost, because CSV parser strip any white space from > the beginning and from the end of the string. So it is safe not to quote > string only if string does not have leading or trailing spaces.
$ perl -MText::CSV_XS -wle'Text::CSV_XS->new({quote_space=>0})->print(*STDOUT,["x"," x","x ","x x"," x x ",1])' x, x,x ,x x, x x ,1 $ perl -MText::CSV_XS -wle'Text::CSV_XS->new({quote_space=>1})->print(*STDOUT,["x"," x","x ","x x"," x x ",1])' x," x","x ","x x"," x x ",1 Works exactly as documented IMHO. If leading or trailing spaces are lost by the parser, blame the parser, not the generator -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
You right. I just noticed this in RFC 4180 (2.4), parser should not ignore spaces. I'm sorry for bothering you for nothing. And thank you again for implementing the feature. Show quoted text
> If leading or trailing spaces are lost by the parser, blame the > parser, > not the generator