Ignorer le champs ignore
This commit is contained in:
11
csvparser.go
11
csvparser.go
@@ -47,16 +47,12 @@ func (p *CsvParser) Parse(line string) (map[string]string, error) {
|
||||
indexMax := len(line) - 1
|
||||
for index, r := range line {
|
||||
if index == indexMax {
|
||||
if currentFieldIndex < len(p.fields) {
|
||||
//fmt.Println("start:", valueStart, "end:", index)
|
||||
//fmt.Println("Found a field value for:", p.fields[currentFieldIndex], line[valueStart:index])
|
||||
if currentFieldIndex < len(p.fields) && p.fields[currentFieldIndex] != "ignore" {
|
||||
if inEnclosedField && r == currentEncloserEnd {
|
||||
ret[p.fields[currentFieldIndex]] = line[valueStart:index]
|
||||
} else {
|
||||
ret[p.fields[currentFieldIndex]] = line[valueStart : index+1]
|
||||
}
|
||||
|
||||
//fmt.Println("Index is:", index)
|
||||
}
|
||||
}
|
||||
if r == '\\' {
|
||||
@@ -67,11 +63,8 @@ func (p *CsvParser) Parse(line string) (map[string]string, error) {
|
||||
}
|
||||
} else if r == p.delimiter {
|
||||
|
||||
if currentFieldIndex < len(p.fields) {
|
||||
//fmt.Println("start:", valueStart, "end:", index)
|
||||
//fmt.Println("Found a field value for:", p.fields[currentFieldIndex], line[valueStart:index])
|
||||
if currentFieldIndex < len(p.fields) && p.fields[currentFieldIndex] != "ignore" {
|
||||
ret[p.fields[currentFieldIndex]] = line[valueStart:index]
|
||||
//fmt.Println("Index is:", index)
|
||||
valueStart = index + 1
|
||||
}
|
||||
currentFieldIndex++
|
||||
|
Reference in New Issue
Block a user