Python Forum
Is there any way to properly load fixed width file into a dataframe using Pandas?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any way to properly load fixed width file into a dataframe using Pandas?
#1
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?
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Formatting cells of a pandas dataframe into an OpenDocument ods spreadsheet Calab 1 821 Mar-01-2025, 04:51 AM
Last Post: Calab
  Find duplicates in a pandas dataframe list column on other rows Calab 2 2,362 Sep-18-2024, 07:38 PM
Last Post: Calab
  Find strings by index from a list of indexes in a different Pandas dataframe column Calab 3 1,698 Aug-26-2024, 04:52 PM
Last Post: Calab
  Add NER output to pandas dataframe dg3000 0 1,208 Apr-22-2024, 08:14 PM
Last Post: dg3000
  HTML Decoder pandas dataframe column mbrown009 3 2,789 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 2,075 Jan-06-2023, 10:53 PM
Last Post: haihal
  export dataframe to file.txt dramauh 5 3,298 Apr-21-2022, 01:23 AM
Last Post: sarahroxon7
  Pandas Dataframe Filtering based on rows mvdlm 0 2,124 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 3,502 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,965 Jan-30-2022, 10:21 AM
Last Post: anto5

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020