JackS
JackS

Reputation: 137

Golang CSV error bare " in non-quoted-field

I haven't had trouble parsing csv files for my GAE golang app until this week (I updated to appengine 1.9.23 last week). Now, regardless of file content I am getting this error:

2015/07/09 15:25:34 http: panic serving 127.0.0.1:50352: line 1, column 22: bare " in non-quoted-field

Even when the file content doesn't contain any " characters at all the error occurs.

Anyone know why my files can no longer be parsed? Something changed or I'm doing something super-stupid.

PS using urlfetch to obtain the csv file

Upvotes: 9

Views: 23465

Answers (3)

James Stallings
James Stallings

Reputation: 96

If the csv decode library follows RFC-4180

If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.

For example:

"aaa","b""bb","ccc"

Upvotes: 2

Anderson Lira
Anderson Lira

Reputation: 478

This happens when we have on CSV file de " (double quotes) value.
To avoid this error we should use LazyQuotes Parameter like that:

csvFile, _ := os.Open("file.csv")
reader := csv.NewReader(bufio.NewReader(csvFile))
reader.Comma = ';'
reader.LazyQuotes = true

Upvotes: 32

JackS
JackS

Reputation: 137

After much ado I determined that the hosting company had updated DotDefender which introduced a rule to block .csv/.tsv arg

Upvotes: 0

Related Questions