How to transform a report that is not a table format into a table format with Python

Viewed 28

I've been struggling a while trying to solve the following issue.

I have some reports in .txt format that in the first 3 rows the metadata is placed, then, the report is displayed as a normal table.

Report Layout viewed in excel

Because of the layout of the report i have to use the following code to read the file

import pandas as pd
df=pd.read_csv('R1.txt', sep='delimiter',header=None)

I use sep='delimiter' because my .txt file is tabular separated file. getting the following:dataframe after reading

how can I take only the "dates" value and have it repeated along into a new column? having this i can erase the metadata rows so i can have the dataframe layout as a table. see example desired dataframe layout

1 Answers

if your separator is a tabular you should use the following

import pandas as pd
df=pd.read_csv('R1.txt', sep='\t',header=None)
Related