AccelerationNet / cl-csv

A common lisp library providing easy csv reading and writing
Other
116 stars 22 forks source link

Reading a CSV file while iterating on another with a different separator appears to use the wrong separator #44

Closed dfmorrison closed 9 months ago

dfmorrison commented 3 years ago

This seems likely to have the same root cause as #43, but just in case not, here's a slightly different issue.

This is cl-csv version 1.0.6, running in SBCL version 2.0.10, on Ubuntu Linux 20.04, on an Intel machine.

With the attached CSV files the following works as expected:

(read-csv #P"letters.csv")

results in

(("a" "b") ("c" "d"))

However, the following

(iter (for (x y) in-csv #P"numbers.txt" separator #\Tab) (collect (list x (read-csv #P"letters.csv") y)))

results in

(("1" (("a,b") ("c,d")) "2") ("3" (("a,b") ("c,d")) "4"))

Expected would instead be

(("1" (("a" "b") ("c" "d")) "2") ("3" (("a" "b") ("c" "d")) "4"))

letters.csv numbers.txt

bobbysmith007 commented 3 years ago

This is likely because the iterate clause rebinds the special variable for separator. I think you could fix this by explicitly passing separator to read-csv, or by binding the special variable around that call