读取文本文件以查找标题,然后在接下来的几行中读取为表格

时间:2018-08-31 10:05:30

标签: python-2.7 pandas

我有一个如下文本文件:

FCT_SALES
--------------------------
select DATE, count(distinct file_name), count (1) from ORV5_ETL.VW_FCT_SALES where DATE BETWEEN '2018-08-27' AND '2018-08-30' group by DATE ORDER BY DATE WITH UR

EVENT_DATE                 2           3          
-------------------------- ----------- -----------
2018-08-27-00.00.00.000000       170    181170
2018-08-28-00.00.00.000000       146    144359
2018-08-29-00.00.00.000000       143    152663
2018-08-30-00.00.00.000000        13    7544

  4 record(s) selected.



real    1m36.643s
user    0m0.014s
sys 0m0.010s
DB20000I  The TERMINATE command completed successfully.

   Database Connection Information

 Database server        = DB2/AIX64 10.5.6
 SQL authorization ID   = ORV5_ETL
 Local database alias   = NGDB

PEOPLE_CAME
----------------
select DATE, count(distinct filename), count (1) from ORV5_ETL.VW_FCT_PEOPLE where DATE BETWEEN '2018-08-27' AND '2018-08-30' group by DATE ORDER BY DATE WITH UR

DATE                       2           3          
-------------------------- ----------- -----------
2018-08-27-00.00.00.000000      1288    846763
2018-08-28-00.00.00.000000      1732    864869
2018-08-29-00.00.00.000000      1619    898555
2018-08-30-00.00.00.000000       506     63426

  4 record(s) selected.

我需要对此进行解析并作为表格阅读。

对此需要一些注意。这样我就可以将其格式化为Excel。

需要删除所有查询和其他文本(标题,列标题除外),并在数据框中格式化数据并输出Excel。

0 个答案:

没有答案