fix(migration): use quoteChar parameter in CSV parser

parseCSV previously ignored the quoteChar parameter (named _). Since
Go's csv.Reader only supports double-quote, we now pre-process the
data to replace alternative quote characters before parsing.
This commit is contained in:
kolaente 2026-03-05 11:21:53 +01:00
parent 46438fc74b
commit 5317a87d90
1 changed files with 9 additions and 1 deletions

View File

@ -279,8 +279,16 @@ func suggestMapping(columns []string) []ColumnMapping {
}
// parseCSV parses CSV data with the given configuration
func parseCSV(data []byte, delimiter, _ string) ([]string, [][]string, error) {
func parseCSV(data []byte, delimiter, quoteChar string) ([]string, [][]string, error) {
data = stripBOM(data)
// Go's csv.Reader only supports double-quote as the quote character.
// If a different quote character is specified, replace it with double-quote
// before parsing so that quoted fields are handled correctly.
if quoteChar != "" && quoteChar != "\"" {
data = bytes.ReplaceAll(data, []byte(quoteChar), []byte("\""))
}
reader := csv.NewReader(bytes.NewReader(data))
if len(delimiter) > 0 {