读取日志文件并获取列而不是行

时间:2014-05-16 16:33:20

标签: windows svn batch-file logging

有一个日志文件,想要将这些行读入Excel的单行列。 目前,它们按行堆叠。我想在反向3> 2> 1

中将3行堆叠成一行
FOR /F "delims=~" %%a in (svn.log)  echo %%a  
set col3 = %%a 
echo col3 col2 col1

有一种简单的方法吗?

输入日志:>>>>

LINE#1 >r132852 | USERID | 2014-05-14 11:57:38 -0700 (Wed, 14 May 2014) | 3 lines
LINE#2 >>>Changed paths:
   M /Customer/lag/inilib/ASIPS_4600.ini
   M /Customer/lag/inilib/ASIPS_4600_TEXT_SEARCH.ini

LINE#3>> Connections tab in Plan Authoring and WO Execution.
LINE#4>> Ques ID: QUES-806 

输出日志:>>>

LINE#4>> Ques ID: QUES-806 LINE#1 >>> r132852 | USERID | 2014-05-14 11:57:38 -0700 (Wed, 14 May 2014) | 3 lines LINE#2 >>>>Changed paths: M /Customer/lag/inilib/ASIPS_4600.ini M /Customer/lag/inilib/ASIPS_4600_TEXT_SEARCH.ini LINE#3 >>> Connections tab in Plan Authoring and WO Execution. ***

输出应该在列的一行中

Input log:
------------------------------------------------------------------------
r132994 | Userid | 2014-05-19 06:22:51 -0700 (Mon, 19 May 2014) | 3 lines
Changed paths:
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_PAGE.sql
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_WORK_ORDER.sql
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_WORK_PLAN.sql

Added messages in try catch to display to the user in case objects do not exist any longer
Ques ID: ASIPS-1003
------------------------------------------------------------------------
r132960 | Userid | 2014-05-17 03:18:09 -0700 (Sat, 17 May 2014) | 3 lines
Changed paths:

modified the command on the product Nodes tab to display either the WO or the page
Ques ID: ASIPS-1003
------------------------------------------------------------------------
r132879 | Userid | 2014-05-15 01:18:32 -0700 (Thu, 15 May 2014) | 4 lines
Changed paths:
M /Customer/Company/IPS/lag/udvlib/ASIPSI_541CA51A7CCB439FB318B8482E380F78.sql

I have forgotten to remove the two buttons I have created for the merge PDF demo. 

Ques ID: ASIPS-1003
------------------------------------------------------------------------
r132878 | Userid | 2014-05-15 01:05:10 -0700 (Thu, 15 May 2014) | 4 lines
Changed paths:
 M /Customer/Company/IPS/lag/udvlib/ASIPSI_541CA51A7CCB439FB318B8482E380F78.sql

Correction of the Tag property for button [Display Object].

Ques ID: ASIPS-1003
------------------------------------------------------------------------
r132834 | Userid | 2014-05-14 09:05:13 -0700 (Wed, 14 May 2014) | 3 lines
Changed paths:
M /Customer/Company/IPS/lag/udvlib/ASIPSI_541CA51A7CCB439FB318B8482E380F78.sql

Display Object in Tab Page Nodes doesn’t display the work order when node type is KO.
Ques ID: ASIPS-1003

需要输出:

Ques ID: ASIPS-1003,  
r132994 | Userid | 2014-05-19 06:22:51 -0700 (Mon, 19 May 2014) | 3 lines
Changed paths:
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_PAGE.sql
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_WORK_ORDER.sql
M /Customer/Company/IPS/lag/message/ASIPSI_MISSING_WORK_PLAN.sql

Added messages in try catch to display to the user in case objects do not exist any longer
------------------------------------------------------------ 
-------------------------------          

以QUES开头的每一行应该是CSV文件中的一行,就像之前只有多个版本和QUES ID

一样

1 个答案:

答案 0 :(得分:0)

在示例文件上测试:

@echo off
< svn.log (
set /p a=
set /p b=
set /p c=
set /p d=
)

for %%a in ("%d%,%c%,%b%,%a%") do >newfile.csv echo %%~a
pause