Skip to content

Add --separator argument to from_csv - #943

Merged
sophiajt merged 2 commits into
nushell:masterfrom
drmason13:from_csv-add-separator-arg
Nov 9, 2019
Merged

sophiajt merged 2 commits into
nushell:masterfrom
drmason13:from_csv-add-separator-arg

Conversation

@drmason13

Copy link
Copy Markdown
Contributor

The command takes an optional named parameter as a string, checks it is a single character and then
passes it to csv::ReaderBuilder via .delimiter() method as a u8.

Mostly implements #932 , only lacking the auto-detection of csv delimiter.

Should allow building a table from semi-colon separated csv files.:

> open from-excel.csv --raw | from-csv --separator ';'

The command takes a string, checks it is a single character and then
passes it to csv::ReaderBuilder via .delimiter() method as a u8.
@gitpod-io

gitpod-io Bot commented Nov 8, 2019 •

Copy link
Copy Markdown

@sophiajt

sophiajt commented Nov 9, 2019

Copy link
Copy Markdown
Contributor

Looks good! Thanks for the PR

@sophiajt
sophiajt merged commit 9043970 into nushell:master Nov 9, 2019
@sophiajt

Copy link
Copy Markdown
Contributor

@drmason13 - think about this a bit more, are you interested in making a similar change to to-csv?

@drmason13

Copy link
Copy Markdown
Contributor Author

Yeah, I'd like to do that. Seems pretty obvious it should work both ways :)

@drmason13

Copy link
Copy Markdown
Contributor Author

Blimey I hardly recognise from_csv :P stuff has been pulled out to from_structured_data.

Would anyone be able to explain how it works now? It looks like it's only able to parse CSV now, the "CSV" string passed by from_csv isn't used as far as I can tell.

I could add a ValidStructuredDataFormats enum (I'm bad at naming things!) which could then lead to using a different library to parse other data types.

It's getting interesting :) I'd love to help have a crack at figuring a clean way of doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants