Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: frank [...] tzone.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.11
Fixed in: 1.17



Subject: FEATURE REQUEST: Parse SEP= parameters used by Excel
Microsoft Excel has the ability to read the field separator used in a CSV file from a "sep=" parameter specified in the first line of that file. This will ensure that the file will be properly parsed no matter the separator specified by the locale settings. (See: https://social.technet.microsoft.com/Forums/office/en-US/ee8f0432-f7d4-4730-84f3-2814eca9c06a/csv-files-arent-delimined-when-opened?forum=excel) Unfortunately, Text::CSV_XS will read that line as a regular line in the CSV file and may alter it. (For instance, it will add quotes if "always_quote" is set to 1, which will break the functionality in Excel. I would suggest that Text::CSV_XS function csv::in should parse that line, use it to set the "sep_char" parameter, and remove the line from the stream provided by the module. Optionally, you could pass a new argument to the "csv" function that would add it back in before writing to a file using csv::out, adjusting it's value if sep_char has been changed.
On Wed Nov 12 17:31:19 2014, frank@tzone.org wrote: Show quoted text
> Microsoft Excel has the ability to read the field separator used in a > CSV file from a "sep=" parameter specified in the first line of that > file. This will ensure that the file will be properly parsed no matter > the separator specified by the locale settings. (See: > https://social.technet.microsoft.com/Forums/office/en-US/ee8f0432- > f7d4-4730-84f3-2814eca9c06a/csv-files-arent-delimined-when- > opened?forum=excel) > > Unfortunately, Text::CSV_XS will read that line as a regular line in > the CSV file and may alter it. (For instance, it will add quotes if > "always_quote" is set to 1, which will break the functionality in > Excel. > > I would suggest that Text::CSV_XS function csv::in should parse that > line, use it to set the "sep_char" parameter, and remove the line from > the stream provided by the module. Optionally, you could pass a new > argument to the "csv" function that would add it back in before > writing to a file using csv::out, adjusting it's value if sep_char has > been changed.
Will be in version 1.17. Still need to write documentation and tests. Still in doubt if it ought to be enabled by default $ cat files/ms1203.csv sep=; "Ħēłļō Ẇȯṙŀḋ";CSV-1203 $ perl -Mblib -MCSV -e'dcsv(in=>"files/ms1203.csv")' [ [ "\x{126}\x{113}\x{142}\x{13c}\x{14d} \x{1e86}\x{22f}\x{1e59}\x{140}\x{1e0b}", 'CSV-1203' ] ]
Subject: Re: [rt.cpan.org #100304] FEATURE REQUEST: Parse SEP= parameters used by Excel
Date: Fri, 24 Apr 2015 10:33:36 -0400
To: "bug-Text-CSV_XS [...] rt.cpan.org" <bug-Text-CSV_XS [...] rt.cpan.org>
From: François Beaulieu <frank [...] TZoNE.ORG>
Show quoted text
> Will be in version 1.17.
Great news! Thanks! Let me know if I can help you test. Show quoted text
> Still in doubt if it ought to be enabled by default
What would be the harm? The presence of that field pretty clearly indicates the author if the CSV file intends for it to be used. Not enabling it produces a stream with superfluous data. -- François Beaulieu (iPhone) (514) 667-0691 x2061
Subject: Re: [rt.cpan.org #100304] FEATURE REQUEST: Parse SEP= parameters used by Excel
Date: Fri, 24 Apr 2015 16:42:30 +0200
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 24 Apr 2015 10:33:54 -0400, "frank@tzone.org via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> > Will be in version 1.17.
> > Great news! Thanks! Let me know if I can help you test.
Just fetch from github as described in the README *ALL* testing is *always* welcome! Show quoted text
> > Still in doubt if it ought to be enabled by default
> > What would be the harm? The presence of that field pretty clearly > indicates the author if the CSV file intends for it to be used.
It is backwards incompatible. The old behavior was completely valid Show quoted text
> Not enabling it produces a stream with superfluous data.
not for people that expect that line to be valid :) Though I currently tend to make this the default behavior and make it an option if people start complaining -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.21 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Download (untitled)
application/pgp-signature 490b

Message body not shown because it is not plain text.

Also available in perl6 version (Text::CSV)