My golang CSV processing routine copies almost exactly from the Package CSV example:
func processCSV(path string){
file:= utils.OpenFile(path)
reader:= csv.NewReader(file)
reader.LazyQuotes = true
cs:= []*Collision{} //defined elsewhere
for {
line, err := reader.Read()
//Kill processing if we're at EOF
if err == io.EOF {
break
}
c := get(line) //defined elsewhere
cs= append(cs, c)
}
//Do other stuff...
}
The code works great until it encounters a malformed (?) line of CSV, which generally looks something like this:
item1,item2,"item3,"has odd quoting"","item4",item5
The csvReader.LazyQuotes = true option doesn't seem to offer enough tolerance to read this line as I need it.
My question is this: can I ask the csv reader for the original line so that I can "massage" it to pull out what I need? The files I'm working with are moderately large (~150mb) and I'm not sure I want to re-do them, especially as only a few lines per file have such problems.
Thanks for any tips!