I have a csv file that has a row of headers and then several dozen lines. When I attempt to read it as a csv, it gets returned as 1 large slice. Why does it not get returned as separate rows? Input looks like:
COL1,COL2
val1,val2
val1,val2
val1,val2
object.Body
is a ReadCloser
lines, err := csv.NewReader(object.Body).ReadAll()
if err != nil {
log.Fatal(err)
}
for _, line := range lines {
log.Print(line)
}
Output is returned as
[COL1 COL2
val1,val2
val1,val2
val1,val2]
I would expect the return to be:
[
[val1, val2],
[val1, val2],
[val1, val2],
]
Any ideas? Totally stumped on this one.
Edit I mistakenly forgot to add a comma in the header. This was only in the sample code, not the actual issue. Sorry for the confusion.
Edit I believe that this issue is due to an encoding of the csv file differently.