Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

CSV delimiter not recognized #175

Closed
yanns opened this issue Apr 29, 2021 · 2 comments · Fixed by #176
Closed

CSV delimiter not recognized #175

yanns opened this issue Apr 29, 2021 · 2 comments · Fixed by #176

Comments

@yanns
Copy link
Contributor

yanns commented Apr 29, 2021

I'm trying the example given in the README:

$ echo "name,age\nhello,32\nkiki,24\n" | http POST 127.0.0.1:9700/documents content-type:text/csv

But this does not create any document.

let headers = csv.headers()?;

returns as headers StringRecord(["name", "age\\nhello", "32\\nkiki", "24\\n"]). I suppose it should return StringRecord(["name", "age"]) instead.

The \n seems to be changed in \\n (or it is only the effect of debugging)

To be noted that I'm testing on mac.

@yanns yanns changed the title CSV delimiter not recoginez CSV delimiter not recognized Apr 29, 2021
@yanns
Copy link
Contributor Author

yanns commented Apr 29, 2021

To test, if I change the code to:

        let content = "name,age\nhello,32\nkiki,24\n";
        let mut csv = csv::Reader::from_reader(content.as_bytes());

then it's working as expected.

@yanns
Copy link
Contributor Author

yanns commented Apr 29, 2021

Arg, the issue is coming from echo
Using printf fixes the issue:

printf "name,age\nhello,32\nkiki,24\n" | http POST 127.0.0.1:9700/documents content-type:text/csv --

See https://stackoverflow.com/questions/8467424/echo-newline-in-bash-prints-literal-n for more info

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant