0

I have an InputData.csv file that looks like:

rec_count,Name,code,status
4,nick,T35,T
7,james,T36,F
10,thomas,T37,T
8,dawson,T38,T
16,nickolas,T39,F
90,ravi,T40,T
22,paul,T41,F
87,matt,T42,F
345,hailey,T43,T
344,nada,T44,T
    

I have been trying to eliminate the commas, add specific paddings to each column. The desired output into the .dat file is the following:

4nick          T35  T
7james         T36  F
10thomas       T37  T
8dawson        T38  T
16nickolas     T39  F
90ravi         T40  T
22paul         T41  F
87matt         T42  F
345hailey      T43  T
344nada        T44  T
    

I don't need the column headers, rec_count has no separator so it stick to Name. Name column is right padded with spaces as much as needed in a way that code column starts at index 16. again as many spaces needed so that status starts at index 21. I also don't need the row count at the left that dataframe outputs.

so far I have tried DataFrame.pad but not much luck. I'm not sure if pandas is the best way to go about this. If you have any other suggestions that could make my life easier i would greatly appreciate it. I don't have to necessarily use pandas.

Adam Lee
  • 1
  • 1

0 Answers0