Skip to content

ENH: Add nrows parameter to pd.read_json #33916

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

Closed
sp1thas opened this issue May 1, 2020 · 1 comment · Fixed by #33962
Closed

ENH: Add nrows parameter to pd.read_json #33916

sp1thas opened this issue May 1, 2020 · 1 comment · Fixed by #33962
Assignees
Milestone

Comments

@sp1thas
Copy link

sp1thas commented May 1, 2020

Is your feature request related to a problem?

Let's say I have a huge jsonlines file and I want to read only the first n lines of the file.

Describe the solution you'd like

This problem could be fixed by adding nrows parameter in method pd.read_json. This parameter should be applicable if and only if lines=True

API breaking implications

Simply add and implement nrows parameter in pd.read_json (like pd.read_csv).

Additional context

How this enhancement could work:

import pandas as pd

df = pd.read_json('/path/to/file.jsonlines', lines=True, nrows=1000)
@sp1thas sp1thas added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels May 1, 2020
@hasnain2808
Copy link
Contributor

Hi @sp1thas ,
I checked the code and I feel, I should be able to implement this feature.

hasnain2808 added a commit to hasnain2808/pandas that referenced this issue May 4, 2020
hasnain2808 added a commit to hasnain2808/pandas that referenced this issue May 4, 2020
@jreback jreback added this to the 1.1 milestone May 20, 2020
@bashtage bashtage removed the Needs Triage Issue that has not been reviewed by a pandas team member label Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants