Parsing CSV with Mixed Delimiters in Go - Unexpected EOF on Line 4
Hey everyone, I'm running into an issue that's driving me crazy. I'm trying to parse a CSV file in Go where the rows use mixed delimiters: some are comma-separated while others use semicolons. My CSV content looks like this: ``` name,age,occupation Alice,30,Engineer Bob;25;Designer Charlie,22;Intern ``` I initially used the `encoding/csv` package to handle the parsing, but when I try to read the file, I encounter an `unexpected EOF` behavior on line 4, which is confusing since I expect the third line to still parse correctly. Here's the code I wrote: ```go package main import ( "encoding/csv" "fmt" "os" ) func main() { file, err := os.Open("data.csv") if err != nil { panic(err) } defer file.Close() reader := csv.NewReader(file) records, err := reader.ReadAll() if err != nil { panic(err) } for _, record := range records { fmt.Println(record) } } ``` I tried modifying the `Comma` field of the `csv.Reader` to handle semicolons, but that seems to throw off the parsing for comma-separated lines as well. I also considered reading the file line by line, but it feels inefficient given that I want to maintain the CSV structure. How can I effectively handle parsing this mixed-delimiter CSV without running into EOF errors? Are there best practices or alternate libraries that might simplify this task? What am I doing wrong?