Compare commits

..

2 Commits

Author SHA1 Message Date
Laurentu 8c241fff65 zz 2025-05-14 15:56:45 +02:00
Laurent Ulrich 62296e1da6 simple tabulation 2024-11-15 15:35:13 +01:00
1 changed files with 8 additions and 6 deletions

View File

@ -14,7 +14,9 @@ type CsvParser struct {
ignore string
maxFieldIndex int
}
func (p *csvParser) FieldCount() int {
return maxFieldIndex + 1
}
/*
* delimiters: string with all delimiter chars
* mergeDelimiters: if true, all successive delimiters are considered as one
@ -107,12 +109,12 @@ func (p *CsvParser) Parse(line string) (map[string]string, error) {
// current rune is a delimiter, a value is present and the next char is the next value
if isDelimiter || index == maxIndex {
if index == maxIndex && valueStart == -1 {
valueStart = 0
}
if index == maxIndex && valueStart == -1 {
valueStart = 0
}
state.delimiter = true
field := line[valueStart:index +1]
field = strings.TrimRight(field,p.delimiters)
field := line[valueStart : index+1]
field = strings.TrimRight(field, p.delimiters)
if state.enclosed {
field = strings.TrimRight(strings.TrimLeft(field, string(state.encloserStart)), string(state.encloserEnd))
}