Skip to content
Advertisement

How to convert this text file into panda tables to make plots?

Here is an image of the text file:

enter image description here

Advertisement

Answer

Try using pd.read_csv and some parameters:

df = pd.read_csv('data.csv', skiprows=3, header=None, sep='s+', comment=',', 
                 names=['z', 'tz', 'tL', 'DA', 'DL'])
print(df)

# Output
       z    tz   tL     DA     DL
0  0.001  13.3  0.1   42.3   43.2
1  0.100  12.2  1.3  380.4  460.3

Content of data.csv:

;###
Omegavac
;;;;
0.001 13.3  0.1 42.3  43.2,,,,
0.1 12.2  1.3 380.4 460.3,,,,
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement