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 [email protected].
For more options, visit https://groups.google.com/d/optout.