The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python Pandas read csv file compressed with gzip and load into Pandas dataframe
By Guest on 30th October 2022 08:28:09 PM | Syntax: PYTHON | Views: 233



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. import pandas as pd
  2.  
  3. df = pd.read_csv('TownshipData.csv.gz', compression='gzip', header=0, sep=' ', quotechar='"', error_bad_lines=False)
  4. df.head(5)
  5.  
  6. >>>     GOVSid,FIPSid,Year4,State_Code,Type_Code,County,Name,FIPS_Code_State,...
  7. 073001001,00093001124045,1972,7,3,1,BETHEL      TOWN,09,001,04720,09001,630,,,10945,,,5645,450...
  8. 073001001,00093001124045,1974,7,3,1,BETHEL      TOWN,09,001,04720,09001,630,,,12285,,,5927,473...
  9.  
  10. #open regular csv file
  11. df = pd.read_csv('/content/TownshipData.csv')
  12. df.head(5)
  13.  
  14. >>>GOVSid       FIPSid  Year4   State_Code      Type_Code       County  Name    FIPS_Code_State ...
  15. 0       73001001        9.300112e+10    1972    7       3       1       BETHEL TOWN     9       1       4720.0  ...     0       0       0       0       0       0       303     0       0       303
  16. 1       73001001        9.300112e+10    1974    7       3       1       BETHEL TOWN     9       1       4720.0  ...     0       0       0       0       0       0       303     0       0       303
















Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.

Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.

See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license
  • Recent Pastes