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

support native open json #2076

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/vaex-core/vaex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def open(path, convert=False, progress=None, shuffle=False, fs_options={}, fs=No
_, ext, _ = vaex.file.split_ext(path)
if ext == '.csv': # special case for csv
return vaex.from_csv(path, fs_options=fs_options, fs=fs, convert=convert, progress=progress, **kwargs)
if ext == ".json": # special case for csv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bogus comment got copy pastad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ext == ".json": # special case for csv
if ext == ".json": # special case for json

return vaex.from_json(path, **kwargs)
if convert:
path_output = convert if isinstance(convert, str) else filename_hdf5
vaex.convert.convert(
Expand Down
8 changes: 8 additions & 0 deletions tests/open_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ def _cleanup_generated_files():
os.remove(hdf5_file)
for hdf5_file in glob.glob(os.path.join(path, '..', 'smæll2*')):
os.remove(hdf5_file)


def test_open_json():
df = vaex.open(csv2)
df.export("test2.json")
df_json = vaex.open("test2.json")
assert len(df) == len(df_json)
_cleanup_generated_files()