My Rails3 app parses user-uploaded CSV files.
As can be expected, users upload tab-separated AND comma-separated files.
I want to support both.
My code:
input = CSV.read(uploaded_io.tempfile, { encoding: "UTF-8", :col_sep => "\t"})
QUESTION:How to change it to support commas too?
FasterCSV's doc describes col_sep as The String placed between each field.
so :col_sep => ",\t"
won't work.
Note: All data inside are integers or identifiers, so the probability of someone using \t
or ,
within the content (not a delimiter) is zero. So usage of the two different delimiters in the same file is not something I expressly want to prevent.