Documentation ¶
Overview ¶
Package macreader changes Classic Mac (CR) line endings to Linux (LF) line endings in files. This is useful when handling CSV files generated by the Mac version of Microsoft Excel as documented in this issue: https://github.com/golang/go/issues/7802.
Example ¶
// testFile is a CSV file with CR line endings. testFile := bytes.NewBufferString("a,b,c\r1,2,3\r").Bytes() // First try reading the csv file the normal way. // The CSV reader doesn't recognize the '\r' line ending. r1 := csv.NewReader(bytes.NewReader(testFile)) lines1, err := r1.ReadAll() if err != nil { fmt.Println(err) } fmt.Printf("Without macreader: %#v\n", lines1) // Now try reading the csv file using macreader. // It should work as expected. r2 := csv.NewReader(New(bytes.NewReader(testFile))) lines2, err := r2.ReadAll() if err != nil { fmt.Println(err) } fmt.Printf("With macreader: %#v\n", lines2)
Output: Without macreader: [][]string{[]string{"a", "b", "c\r1", "2", "3"}} With macreader: [][]string{[]string{"a", "b", "c"}, []string{"1", "2", "3"}}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.