See: https://github.com/golang/go/issues/7897
See also: https://gist.github.com/ajstarks/04a61ace4fc8e18f51fda8da6adac017 for a program I use to read CSVs on a Mac. I typically use "Windows Comma Separated" when saving from Excel. On Monday, July 17, 2017 at 11:07:43 PM UTC-4, Matt Harden wrote: > > I suspect that this has to do with the line-ending characters on a Mac. I > think Excel is writing the file with each line ending with a CR character. > The encoding/csv package expects RFC 4180 format (each line terminated with > CRLF), which is what Excel writes when you select "Windows Comma Separated". > > I don't know a super-easy way to make encoding/csv accept the first format. > > On Mon, Jul 17, 2017 at 4:42 PM Dat Huynh <audat...@gmail.com > <javascript:>> wrote: > >> Hi all, >> >> I have a problem with parsing a .csv file using the library >> "encoding/csv". >> >> I wonder if that is the problem of Microsoft Excel or the Go library. >> >> I am using Microsoft Excel version 14.2.2 on MacOS and go1.8.3 >> darwin/amd64 >> >> What did I do? >> >> Firstly I input the below values into an Excel sheet, and save as a .csv >> file. >> value 11 value 12 >> value 21 value 22 >> value 31 value 32 >> >> If I choose "Comma Separated Values (.csv)" in the option "Format", type >> the file name "data.csv", and run my Go app, it returns: >> >> $ go run demo.go >> value 31 value 32]12 >> >> If I choose "Window Comma Separated (.csv)" in the option "Format", type >> the file name "data.csv", and run my Go app, it works well. >> >> $ go run demo.go >> 0 [value 11 value 12] >> 1 [value 21 value 22] >> 2 [value 31 value 32] >> >> Could you please confirm if this is a bug of the library or MS Excel? >> >> Below is my code. >> >> package main >> >> import ( >> "encoding/csv" >> "fmt" >> "os" >> ) >> >> func main() { >> file, _ := os.Open("data.csv") >> defer file.Close() >> csvReader := csv.NewReader(file) >> records, _ := csvReader.ReadAll() >> for index, record := range records { >> fmt.Println(index, record) >> } >> } >> >> Thank you very much. >> >> Regards, >> Dat Huynh. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.