Hi,
I have nonstandard CSV file with semicolon instead of comma as a separator and cp1251 encoded. Documentation is not clear in this case, and the sample doesn't work properly
declare %rest:path("/store.csv") %rest:POST("{$csv}") %input:csv("header=true") function page:store-csv($csv as document-node()) { "Number of rows: " || count($csv/csv/record) };
Even if I changed the encoding manually the next code does nothing %input:csv("separator=semicolon") and returns text instead of document-node()
Could you check it?
It would be nice if you add additional encoding parameter to csv module.
Thanks!
Hi Alex,
The following annotation should do what you want:
%input:csv("header=true,encoding=CP1252")
You were completely right, the existing documentation was a bit scrappy. I have slightly rewritten it (see [1] and outgoing links).
Hope thie helps, Christian
[1] http://docs.basex.org/wiki/RESTXQ#Input_options
On Sun, Jun 12, 2016 at 4:03 PM, Alexander Shpack shadowkin@gmail.com wrote:
Hi,
I have nonstandard CSV file with semicolon instead of comma as a separator and cp1251 encoded. Documentation is not clear in this case, and the sample doesn't work properly
declare %rest:path("/store.csv") %rest:POST("{$csv}") %input:csv("header=true") function page:store-csv($csv as document-node()) { "Number of rows: " || count($csv/csv/record) };
Even if I changed the encoding manually the next code does nothing %input:csv("separator=semicolon") and returns text instead of document-node()
Could you check it?
It would be nice if you add additional encoding parameter to csv module.
Thanks!
basex-talk@mailman.uni-konstanz.de