Created
March 19, 2016 22:15
-
-
Save autocorr/45728bf378371150aef1 to your computer and use it in GitHub Desktop.
Reading a CDS fixed width table into a pandas dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from astropy import table | |
# use the astropy table reader method to read the file and convert | |
# to a `pandas.DataFrame` | |
df = table.Table.read('table1.txt', format='ascii.cds').to_pandas() | |
df.to_csv('table1.csv', index=False) | |
# when reading the files, remember to set the index column for | |
# matching and other things | |
df = pd.read_csv('table1.csv', index_col='Seq') # index for that table | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment