jsonp
: add jsonp
command allowing non-nested JSON to CSV conversion with Polars
#1880
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1878 covers the example and use case for this new command
qsv jsonp
.Excerpt from
qsv jsonp --help
Convert non-nested JSON to CSV (polars feature only). You may provide JSON data either from stdin or a file path. This command may not work with nested JSON data.
As a basic example, say we have a file
fruits.json
with contents:To convert it to CSV format, run:
And the following is printed to the terminal:
If
fruits.json
was provided using stdin then either use-
or do not provide a file path. For example:cat fruits.json | qsv jsonp -
Sample usage
Create a CSV file
fruits.csv
based onfruits.json
:cat fruits.json | qsv jsonp -o fruits.csv
Print to terminal the converted CSV data from a JSON file you may pick from a file dialog which is filtered to show
.json
files only:qsv prompt -F json | qsv jsonp
Potential improvements
polars
feature being enabled, so an implementation without the feature being enabled and converting this command fromjsonp
tojson
is a potential improvement.