-
Notifications
You must be signed in to change notification settings - Fork 18k
encoding/csv: Feature request: Specify record delimiter #12372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
you can wrapper the io.Reader with another that translate \r to \n.
|
That's fair. Thing is, I could also wrap a TSV with a reader that converts tabs to commas, but csv.Reader.Comma exists all the same. Because .Comma exists, I figured the design goal of csv.Reader was probably convenience rather than strict RFC compliance, hence my suggestion. |
Converting tabs to commas is a little harder, because you have to handle
quoting,
but converting \r to \n doesn't.
|
Actually, I think you do have to handle quoting for newlines in the same way - see RFC 4180 section 2.6. Commas, newlines, and double quotes can all exist within double quoted-fields. |
If I had it to do over I would remove Comma. Old mistakes aren't justification for new ones. If a global \r => \n conversion isn't appropriate, it's certainly easy to make a copy of encoding/csv and adjust it for your purposes. I don't believe this problem is widespread enough to justify more complexity in this already complex package. Thanks. |
CL https://golang.org/cl/23401 mentions this issue. |
The intent of this comment is to reduce the number of issues opened against the package to add support for new kinds of CSV formats, such as issues #3150, #8458, #12372, #12755. Change-Id: I452c0b748e4ca9ebde3e6cea188bf7774372148e Reviewed-on: https://go-review.googlesource.com/23401 Reviewed-by: Andrew Gerrand <[email protected]>
It would be great to be able to specify a record delimiter for a csv.Reader. For me, I need to parse CSVs with Mac OS 9 line termination (\r only).
(I'm using Go 1.5 on Mac OS 10.10.5.)
The text was updated successfully, but these errors were encountered: