-
Notifications
You must be signed in to change notification settings - Fork 2.1k
combine csv and tsv functions behind [to/from]-[csv/tsv] commands #969
Description
Following on from #943 where a separator arg was added to from-csv.
I've now realized that from-tsv is just a specific case of from-csv (tab separated values).
I've also noticed that passing --separator "\t" to from-csv trips my uninspired check for a single character (it sees two characters, '' and 't').
I'd like to propose having from-tsv and from-csv --separator "\t" do the same thing, and I think we can deduplicate some code while we're at it. And I'm planning to make a pull request with these changes :)
-
[from/to]_tsv can call the same function as [from/tp]_csv, this has already been started with
from_structured_data. Only, I think the scope of this module would be more clear if we named itfrom_delimited_data. This will usecsv::ReaderBuilderandcsv::WriterBuilderwith different delimiters. -
the parsing of the separator arg of from_csv and to_csv should be improved. I struggled to get a character out of nu from the command line and ended up checking a
string.to_chars()has length 1. I can check if the string is "\t" first and return '\t' early for now but I worry that's symptomatic of a deeper issue? Are there plans for supporting characters from the command line? I'd be interested in the why/why not and how?
Also a side note: maybe --delimiter should be added as an alias for --separator?