Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite-utils should suggest --csv if JSON parsing fails #206

Closed
simonw opened this issue Dec 11, 2020 · 4 comments
Closed

sqlite-utils should suggest --csv if JSON parsing fails #206

simonw opened this issue Dec 11, 2020 · 4 comments
Labels
cli-tool enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Dec 11, 2020

~ % gsutil cat gs://ossf-criticality-score/python_top_200.csv | sqlite-utils insert /tmp/crit.db crit -
...
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

A nicer error message here would be one that says the JSON is invalid but suggests that maybe you could try --csv.

@simonw simonw added the enhancement New feature or request label Dec 11, 2020
@simonw simonw added the cli-tool label Jan 3, 2021
@simonw
Copy link
Owner Author

simonw commented Jan 3, 2021

% sqlite-utils insert blah.db blah global_power_plant_database.csv
Error: Invalid JSON - use --csv for CSV or --tsv for TSV files

@simonw simonw closed this as completed in 1e38a16 Jan 3, 2021
simonw added a commit that referenced this issue Jan 3, 2021
@dufferzafar
Copy link

@simonw Hey! JSON parsing for me is failing and I'm getting this same error, but I feel that my json is correct. How can I debug this?

@simonw
Copy link
Owner Author

simonw commented Oct 30, 2021

What's the error message?

Sometimes I pipe JSON through jq to check if it's valid:

cat my.json | jq

@dufferzafar
Copy link

@simonw That was working fine. It turned out that I had to use --nl flag since I was passing in jsonl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli-tool enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants