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

open-cell (zo) should open the correct filetype in cell #2327

Open
dufferzafar opened this issue Feb 21, 2024 · 4 comments
Open

open-cell (zo) should open the correct filetype in cell #2327

dufferzafar opened this issue Feb 21, 2024 · 4 comments

Comments

@dufferzafar
Copy link
Contributor

If I've opened the current sheet as a jsonl but the cell that I'm on has a CSV url?

Currently I get:

opening http://url/to/file.csv as jsonl
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Where it tries to open a CSV file as JSONL for some reason.

Originally posted by @dufferzafar in #1514 (comment)

@dufferzafar
Copy link
Contributor Author

Reproduce it like so:

cat > /tmp/t.json
[
    {
        "type": "csv",
        "url": "https://raw.githubusercontent.com/duckdb/duckdb/main/data/csv/aws_locations.csv"
    },
    {
        "type": "json",
        "url": "https://raw.githubusercontent.com/duckdb/duckdb/main/data/json/issue.json"
    },
    {
        "type": "jsonl",
        "url": "https://raw.githubusercontent.com/duckdb/duckdb/main/data/json/duplicate_key.ndjson"
    }
]
vd /tmp/t.json
# try to use zo on cells, and it works correctly!
vd -f json /tmp/t.jsonn
# try to use zo on cells, and it will consider everything to be json

cc: @anjakefala

@dufferzafar
Copy link
Contributor Author

I just figured out that this only happens if you open the file with a specific format -f json, so I've removed it from my current scripts and things work for me.

@saulpw
Copy link
Owner

saulpw commented Feb 21, 2024

Glad you were able to find a workaround, @dufferzafar! You might also try -n -f json <foo.json> to apply the option only to the given path, and not globally.

@justin2004
Copy link
Contributor

justin2004 commented Feb 21, 2024

what would be a good way to open the file in the cell but as type f? this is in case the file doesn't have an extension.

the only way i've come up with is to use my repl and eval:
say if you have an email file

vd.push(vd.open_eml(Path(vd.sheet.cursorDisplay)))

i guess i could turn that into a command but i need to pass in the filetype e.g. "eml" "xlsx" etc.

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

No branches or pull requests

3 participants