How to parse data from .TX0 file into dataframe

72 Views Asked by At

Hi I'm trying to basically convert a .TX0 file from a chromatogram file. the file is just a bunch of results including retention times etc... I want to eventually pick certain pieces of data from multiple files and do some analysis. So far I have:

filename = 'filepath'
f = open(filename, 'r')
lines = f.readlines()
print lines

my output is:

Out[29]: 
[....................................................



 '"condensate analysis (HP4890 Optic - FID)"\n',
 '"Peak","Component","Time","Area","Height","BL"\n',
 '"#","Name","[min]","[uV*sec]","[uV]",""\n',
 '------,------,------,------,------,------\n',


'1,"Methane",0.689,5187666.22,994337.57,*BB\n',
 '2,"Ethane",1.061,1453339.93,729285.09,*BB\n',
 '3,"Propane",1.715,193334.09,63398.74,*BB\n',
 '4,"i-Butane",2.792,157630.92,29233.56,*BV\n',
 '5,"n-Butane",3.240,98943.96,15822.72,*VB\n',
 '"","","",------,------,""\n',
 '"","","",7090915.11,1.83e+06,""\n',
 '"Missing Component Report"\n',
 '"Component","Expected Retention (Calibration File)"\n',
 '------,------\n',
 '"All components were found"\n',
 '"Report stored in ASCII file :","...
 "\n'.......................]

Now, the problem i'm having. I can't get this output into a structured dataframe using pandas... =/ I've tried and it just gives me two columns...

pd.DataFrame(filename)

out:

Out[26]: 
                                                    0
0   "=============================================...
1   "Software Version:",6.3.2.0646,"Date:","08/06/...
2             "Reprocess Number:","vma2: ......................
.......................
10                                               ""\n
11                                               ""\n
12       "condensate analysis (HP4890 Optic - FID)"\n
13   "Peak","Component","Time","Area","Height","BL"\n
14          "#","Name","[min]","[uV*sec]","[uV]",""\n
15        ------,------,------,------,------,------\n
16       1,"Methane",0.689,5187666.22,994337.57,*BB\n
17        2,"Ethane",1.061,1453339.93,729285.09,*BB\n
18         3,"Propane",1.715,193334.09,63398.74,*BB\n
19        4,"i-Butane",2.792,157630.92,29233.56,*BV\n
20         5,"n-Butane",3.240,98943.96,15822.72,*VB\n
21                        "","","",------,------,""\n
22                  "","","",7090915.11,1.83e+06,""\n
23                       "Missing Component Report"\n
24  "Component","Expected Retention (Calibration F...
25                                    ------,------\n
26                      "All components were found"\n
27  "Report stored in ASCII file :","C:\Shared Fol...
0

There are 0 best solutions below