I have a .txt file with data ordered as below:
R11
R12
R13
R14
R15
R16
R17
R18
R19
R20
I need to iterate over rows in the textfile to fill the columns per row. In other words, the data need to be transformed to a pandas DataFrame looking like this:
| Column1 | Column2 | Column3 | Column4 | Column5 |
|---------|---------|---------|---------|---------|
| R11 | R12 | R13 | R14 | R15 |
| R16 | R17 | R18 | R19 | R20 |
My code starts with the following. After running, I now have a list of all rows called data, but how to get a pandas DataFrame as above as output?
with open('data.txt','r') as file:
data = file.read().split('\n')

pd.DataFrame(pd.read_csv('data.txt', names=[0]).values.reshape(-1,5))