找到特定的文本并将其附加到文本文件php的特定部分

时间:2016-05-18 05:41:20

标签: javascript php jquery mysql

我有从现场仪器导入的文本文件。输出文件是' txt'并显示如下;

    AUTO DATA  51            
  DATE       TIME     FID BACKGROUND        FID CONCENTRATION                   GPS DATA                
---------  --------  --------------------  -------------------------------------------------------------
15 MAY 16  08:38:35     0.0 PPM OK            8.7 PPM OK          37.46009 -121.94495   32  6  7 
15 MAY 16  08:38:40     0.0 PPM OK            9.5 PPM OK          37.46009 -121.94495   32  6  7 
15 MAY 16  08:38:45     0.0 PPM OK            119 PPM HIGH_ALRM   37.46009 -121.94495   32  6  7 
15 MAY 16  08:38:50     0.0 PPM OK           53.4 PPM HIGH_ALRM   37.46009 -121.94495   32  6  7 
15 MAY 16  08:38:55     0.0 PPM OK           36.3 PPM OK          37.46009 -121.94495   32 21  4 

AUTO DATA  52           
  DATE       TIME     FID BACKGROUND        FID CONCENTRATION                   GPS DATA                
---------  --------  --------------------  -------------------------------------------------------------
15 MAY 16  08:40:27     0.0 PPM OK           21.2 PPM OK          37.45982 -121.94486   26  7  6 
15 MAY 16  08:40:32     0.0 PPM OK           17.7 PPM OK          37.45982 -121.94486   26  6  7 
15 MAY 16  08:40:37     0.0 PPM OK           17.5 PPM OK          37.45979 -121.94493   26  6  7 
15 MAY 16  08:40:42     0.0 PPM OK           12.5 PPM OK          37.45976 -121.94502   27  6  7 
15 MAY 16  08:40:47     0.0 PPM OK           13.6 PPM OK          37.45976 -121.94504   27  6  7 
15 MAY 16  08:40:52     0.0 PPM OK           16.9 PPM OK          37.45976 -121.94504   27  6  7 
15 MAY 16  08:40:57     0.0 PPM OK           18.0 PPM OK          37.45976 -121.94504   27  6  7 
15 MAY 16  08:41:02     0.0 PPM OK           31.6 PPM OK          37.45976 -121.94504   27  6  7 
15 MAY 16  08:41:07     0.0 PPM OK           28.4 PPM OK          37.45971 -121.94518   23  6  7 
15 MAY 16  08:41:12     0.0 PPM OK           23.6 PPM OK          37.45968 -121.94518   21  7  6 
15 MAY 16  08:41:17     0.0 PPM OK           63.5 PPM OK          37.45968 -121.94518   21  7  6 
15 MAY 16  08:41:22     0.0 PPM OK            294 PPM HIGH_ALRM   37.45968 -121.94518   21  7  6 
15 MAY 16  08:41:27     0.0 PPM OK            212 PPM HIGH_ALRM   37.45968 -121.94518   21  7  5 

AUTO DATA  53           
  DATE       TIME     FID BACKGROUND        FID CONCENTRATION                   GPS DATA                
---------  --------  --------------------  -------------------------------------------------------------
15 MAY 16  08:42:46     0.0 PPM OK           21.0 PPM OK          37.45963 -121.94547   23  6  7 
15 MAY 16  08:42:51     0.0 PPM OK           27.3 PPM OK          37.45963 -121.94547   23  7  5 

我需要做的是抓住AUTO DATA *号并将其附加到所有行,然后更改为下一个号码,冲洗并重复并生成类似的内容;

AUTO DATA  51            
  DATE       TIME     FID BACKGROUND        FID CONCENTRATION                   GPS DATA                
---------  --------  --------------------  -------------------------------------------------------------
51 15 MAY 16  08:38:35     0.0 PPM OK            8.7 PPM OK          37.46009 -121.94495   32  6  7 
51 15 MAY 16  08:38:40     0.0 PPM OK            9.5 PPM OK          37.46009 -121.94495   32  6  7 
51 15 MAY 16  08:38:45     0.0 PPM OK            119 PPM HIGH_ALRM   37.46009 -121.94495   32  6  7 
51 15 MAY 16  08:38:50     0.0 PPM OK           53.4 PPM HIGH_ALRM   37.46009 -121.94495   32  6  7 
51 15 MAY 16  08:38:55     0.0 PPM OK           36.3 PPM OK          37.46009 -121.94495   32 21  4 

AUTO DATA  52           
  DATE       TIME     FID BACKGROUND        FID CONCENTRATION                   GPS DATA                
---------  --------  --------------------  -------------------------------------------------------------
52 15 MAY 16  08:40:27     0.0 PPM OK           21.2 PPM OK          37.45982 -121.94486   26  7  6 
52 15 MAY 16  08:40:32     0.0 PPM OK           17.7 PPM OK          37.45982 -121.94486   26  6  7 
52 15 MAY 16  08:40:37     0.0 PPM OK           17.5 PPM OK          37.45979 -121.94493   26  6  7 
52 15 MAY 16  08:40:42     0.0 PPM OK           12.5 PPM OK          37.45976 -121.94502   27  6  7 
52 15 MAY 16  08:40:47     0.0 PPM OK           13.6 PPM OK          37.45976 -121.94504   27  6  7 
52 15 MAY 16  08:40:52     0.0 PPM OK           16.9 PPM OK          37.45976 -121.94504   27  6  7 
52 15 MAY 16  08:40:57     0.0 PPM OK           18.0 PPM OK          37.45976 -121.94504   27  6  7 
52 15 MAY 16  08:41:02     0.0 PPM OK           31.6 PPM OK          37.45976 -121.94504   27  6  7 
52 15 MAY 16  08:41:07     0.0 PPM OK           28.4 PPM OK          37.45971 -121.94518   23  6  7 
52 15 MAY 16  08:41:12     0.0 PPM OK           23.6 PPM OK          37.45968 -121.94518   21  7  6 

目的是使用' AUTO DATA'作为mysql数据库的列。目前,我已将文本文件导入到&{39; xlsb'文件,我使用宏来处理转换并生成' csv'要上传到数据库的文件。最终目标是让用户上传' txt'直接将文件存入数据库,在线。任何帮助将不胜感激,我当然愿意研究任何建议。提前致谢。

0 个答案:

没有答案