如何将.TX0文件中的数据解析为数据帧

时间:2015-06-08 15:38:48

标签: python pandas dataframe

您好我正在尝试从色谱图文件中基本转换.TX0文件。该文件只是一堆结果,包括保留时间等...我想最终从多个文件中选择某些数据并进行一些分析。到目前为止,我有:

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

我的输出是:

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'.......................]

现在,我遇到的问题。我无法使用pandas将此输出转换为结构化数据框... = /我已经尝试过它只给了我两列......

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 个答案:

没有答案