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

How to get first 1000 rows in very big csv file #6

Open
byhbt opened this issue Jun 27, 2020 · 0 comments
Open

How to get first 1000 rows in very big csv file #6

byhbt opened this issue Jun 27, 2020 · 0 comments
Labels
Python Learn Python

Comments

@byhbt
Copy link
Owner

byhbt commented Jun 27, 2020

Problem:

The csv file quite big ~25MB, and a quite difficult to process in Excel/Numbers/Spreadsheet software.
As a programmer, I want to get the first 1000 rows using Python.

Solution:

import pandas as pd

df = pd.read_csv("DATA_CUSTOM.csv")

print(df.head(2000).to_csv("export-1k-rows.csv"))

Lesson:

  • Find a smart way to process things.
  • Take advantage of programming language and library, for example in this case are: python and pandas.
@byhbt byhbt added the Python Learn Python label Jun 27, 2020
@byhbt byhbt added this to the First 50 issues milestone Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python Learn Python
Projects
None yet
Development

No branches or pull requests

1 participant