Comments (7)
Sorry, but you did not mention one critical issue that causes the behavior you see, as in the default setup, it works exactly as documented:
$ perl -MText::CSV_XS -e'Text::CSV_XS->new->say(*STDOUT,[map{$_//"\\N"}"blah",undef,3])'
blah,\N,3
But I am sure you have setup your instance with { escape => "\\" }
, which causes the need to escape the escape, and fields that have escapes in them are automatically quoted:
$ perl -MText::CSV_XS -e'Text::CSV_XS->new({escape=>"\\"})->say(*STDOUT,[map{$_//"\\N"}"blah",undef,3])'
blah,"\\N",3
I'll see if there can be a more explicit attribute to achieve this, as callbacks are not an option to make this combination work.
from text-csv_xs.
Try a pull/clone from here. I added the undef_str
attribute:
$ perl -Mblib -MText::CSV_XS -e'Text::CSV_XS->new({escape=>"\\",undef_str=>"\\N"})->say(*STDOUT,["blah",undef,3])'perl -Mblib -MText::CSV_XS -e'Text::CSV_XS->new({escape=>"\\",undef_str=>"\\N"})->say(*STDOUT,["blah",undef,3])'
blah,\N,3
See https://github.com/Tux/Text-CSV_XS/blob/master/doc/CSV_XS.md#undef_str
from text-csv_xs.
Wow, that's great! Thankyou so much for the fast response and patch.
from text-csv_xs.
Feedback would be more than welcome BTW.
I saw it failed tests on 5.18.x and below, so I cannot release yet.
(and I just pushed a patch that allows UTF-8 values for undef_str
, where ∅
(U+002205) springs to mind as useful :)
from text-csv_xs.
@dankasak would you be so kind to pull/clone again? I changed a lot of code to make it work on 5.18.x and below. If my tests do not cover all issues, your code might.
Any other feedback for now?
from text-csv_xs.
I've pulled and re-tested, using a couple of options for supporting different databases. Looks good to me :)
from text-csv_xs.
Thanks for the feedback. I'll start the big test-to-release process
from text-csv_xs.
Related Issues (20)
- csv() cannot have both in and out be filenames HOT 3
- Wishlist: ability to throw exception if formula seen in CSV HOT 8
- _is_arrayref, _is_hashref and _is_coderef is incorrectly defined HOT 9
- Add an option to the csv function to neither return nor print anything HOT 3
- csv2xls does not like (nearly) empty files HOT 3
- Calling $csv->header breaks auto_diag in 1.40 HOT 8
- csv munge_column_names function fails with sep=; header HOT 1
- getter quote_char() and escape_char() returning 0 instead of undef HOT 5
- Can't parse fields with nested quotes and commas HOT 2
- Offer option to not put empty columns into hashes created HOT 1
- Procedure (or method) returning the error text HOT 2
- csv in => $aoa, out => … produces a CSV file with two empty records when $aoa is empty HOT 2
- Turn off column naming munging HOT 2
- Multiple spaces as a separator? HOT 3
- Typo in sub csv() causes sep chars set to not work HOT 2
- getline_all does not understand scientific ("e") notation HOT 2
- BOM without a header line. HOT 6
- POD: Decide if it is $fh or $io HOT 1
- skip empty or blank HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from text-csv_xs.