Skip to content

Instantly share code, notes, and snippets.

@JasonCrowe
Created October 10, 2017 19:22
Show Gist options
  • Save JasonCrowe/ddf885a2ca93cc2074fc572111d06948 to your computer and use it in GitHub Desktop.
Save JasonCrowe/ddf885a2ca93cc2074fc572111d06948 to your computer and use it in GitHub Desktop.
Pandas fixed-width data source
import pandas as pd
df = pd.read_csv('file.tab', sep='\t', lineterminator='\r')
import pandas as pd
fwidths = [34, 4, 4, 34, 11, 1, 1, 1, 1, 1, 8, 8, 2, 11, 1, 40, 1, 40, 1, 7, 7, 1, 1, 1, 4, 40, 40, 40, 40, 40, 2, 12, 1, 8, 40, 1, 11, 11, 11, 11, 1 ]
df = pd.read_fwf('file.tab', widths = fwidths, names = ['ACCOUNT', 'YEAR', 'JURISDICTION', 'TAX-UNIT-ACCT', 'LEVY', 'HOMESTEAD', 'OVER65', 'VETERAN', 'DISABLED', 'AG', 'DATE-PAID', 'DUE-DATE', 'OMIT-FLAG', 'LEVY-BALANCE', 'SUIT', 'CAUSENO', 'BANKCODE', 'BANKRUPTNO', 'ATTORNEY', 'COURT-COST', 'ABSTRACT-FEE', 'DEFERRAL', 'BILLSUPP', 'SPLIT-PMTFLAG', 'CATEGORY-CODE', 'OWNER', 'ADDRESS2', 'ADDRESS3', 'ADDRESS4', 'CITY', 'STATE', 'ZIP', 'ROLL-CODE', 'PARCEL NO.', 'PARCEL NAME', 'PAYMENT AGREEMENT', 'TOT_AMT_DUE', 'TOT_AMT_DUE-30', 'TOT_AMT_DUE-60', 'TOT_AMT_DUE-90', 'AMOUNT INDICATOR'])
df[:10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment