Python Forum

Full Version: Is there any way to properly load fixed width file into a dataframe using Pandas?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Is there any way to properly load and write fixed width file into a dataframe using Pandas?

I'm trying to load a fixed width file using pandas read_fwd as below, but the spaces are getting trimmed now.

input_df = pd.read_fwf('fwfile', widths=[24,4,59,28,2,12,121], skiprows=0, parse_dates=True, dtype=str)
Can you guys please suggest any solution for this issue?
Please supply a short (just a few lines) file to work with.
If you use 'New Reply' button, rather than Quick Reply, you can attach the file.