pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.65k stars 17.92k forks source link

read_csv can't read right-aligned columns delimited by spaces #6513

Closed sealauren closed 10 years ago

sealauren commented 10 years ago

screenshot 2014-02-28 18 02 06 I often work with tables that are right aligned and space delimited. This means that the spaces in front of the first column varies from 0 to N. In this screenshot, this transition happens from 999 to 1000. I would like pandas to figure out that the first non-space values in each row all belong to the same column. Using skipinitialspace=True does not work (since some rows have no space at all), and so some of the values get pushed into the wrong column!

jreback commented 10 years ago

try using read_fwf this is exactly want it does you can also specific the structure of the columns as well

sealauren commented 10 years ago

Thank you!