Skip to content
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

encoding/csv: Classic Mac (CR) line delimiters not supported #7802

Closed
gopherbot opened this issue Apr 17, 2014 · 8 comments
Closed

encoding/csv: Classic Mac (CR) line delimiters not supported #7802

gopherbot opened this issue Apr 17, 2014 · 8 comments

Comments

@gopherbot
Copy link

by olegs.denisovs:

Windows (CRLF) and Unix (LF) line delimiters work fine, but if I try to read csv file
with Classic Mac (CR) line delimiters then it works incorrectly.
@bradfitz
Copy link
Contributor

Comment 1:

I think you'll find most of the standard library won't deal with Classic Mac (CR) files.
You'll probably want to write your io.Readers with a CR-to-CRLF io.Reader.

@gopherbot
Copy link
Author

Comment 2 by MattieuGA:

FWIW, The current version of Excel on the current version of Mac OSX uses CR as a line
delimiter. It's not uncommon to have those files hit your server if your are allowing
user generated content.

@ianlancetaylor
Copy link
Contributor

Comment 3:

The package operates as documented.  There is a workaround.  I'm not sure what we can do
here at this point.

Status changed to Unfortunate.

@bdaglish
Copy link

FWIW, I seem to have fixed it by changing readRune in reader.go to do this..

if r1 == '\r' {
    r1, _, err = r.r.ReadRune()
    if err == nil  && r1 != '\n' {
        r.r.UnreadRune()
    }
    r1='\n'
}

Shall I submit a patch?

@bradfitz
Copy link
Contributor

No, we're not going to modify things ad hoc to support Classic Mac OS line endings. Consider the encoding/csv package effectively frozen.

@dominikh
Copy link
Member

Writing your own io.Reader that does whatever modification is necessary is fairly straightforward and the right solution for dealing with non-standard input. Changing encoding/csv is not.

@mdwhatcott
Copy link

In my work I see a lot of classic mac os line endings so a patch would be a very welcome addition. Looks like I'm going to Implement a reader to adapt '\r' to '\n'.

@ctessum
Copy link

ctessum commented Oct 5, 2015

In case anyone ends up here in the future, there is an implementation of the workaround described above here: https://godoc.org/github.com/ctessum/macreader

@golang golang locked and limited conversation to collaborators Oct 4, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants