1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

csv: fix last-field-empty error

This commit is contained in:
yuyi
2020-04-29 22:50:02 +08:00
committed by GitHub
parent 3e4cd12fd0
commit b2a076e8b8
2 changed files with 40 additions and 12 deletions

View File

@ -129,18 +129,19 @@ fn (r mut Reader) read_record() ?[]string {
// quoted
else {
line = line[1..]
if j := line.index('"') {
if j+1 == line.len {
// last record
fields << line[..j]
break
}
next := line[j+1]
if next == r.delimiter {
fields << line[..j]
line = line[j..]
continue
}
j := line.index('"') or {
break
}
if j+1 == line.len {
// last record
fields << line[..j]
break
}
next := line[j+1]
if next == r.delimiter {
fields << line[..j]
line = line[j..]
continue
}
line = line[1..]
}