I have a file which I'm trying to convert into data frame using pandas. It is inside a loop and returns me the output as shown below. Here is the code I'm using:
import pandas as pd
import csv
with open('File.tbl', 'r') as f:
P=list(f)
del P[0]
for o in P:
M=o.split()
B= M[:4] #selecting specific columns only
E= pd.DataFrame(B) #converting into DataFrame
print(E)
G.to_csv('para.csv', sep=',')
Here the tbl file is not tab seperated and to create a tab separation, I've to convert it into list. Here is the reult I'm getting:
0 B
1 244
2 S
3 0
0
0 B
1 245
2 A
3 0
The expected output is like this:
0 B 244 S 0
0 B 245 A 0
Any help will be highly appreciated.