i need to remove \n but i have to do it just for 4 lines

August 6, 2012 at 23:58:45
Specs: Windows 7
i need to remove \n but i have to do it just for 4 lines for all CSV; i mean lines are just like that;

Log Serial Number,Object Identity Name,Object Identity,ProductName,NEType,NE Object Identity,Alarm Source,EquipmentAlarmSerialNumber,AlarmName,Type,Severity,OccurrenceTime,LocationInformation,LinkFDN,LinkName,LinkType,Alarm Identifier,Alarm ID,Object Instance Type,business Affected,addtional Text,arrivedUtcTime,agent ID,root Id,show Flag
22917896,.OMCNE.0.PM,.OMCNE.0.PM,NMS,OMC,.OMCNE.0,OMC,0,Performance Result Loss,Internal,Critical,2012/7/24 19:38:45 GMT+02:00 DST,"Cause=The performance result is missing.,
NE=SMSH1,
MU=956301759,
Time Segment=[2012-07-24 18:45:00 DST~2012-07-24 19:00:00 DST]",,,,,407,,,"FDN=.3221229568.3221278720.3221291131,
Period=15 min,
NE Type=SOFTX3000NE",2012/7/24 19:38:45 GMT+02:00 DST,,,0
22917897,.OMCNE.0.PM,.OMCNE.0.PM,NMS,OMC,.OMCNE.0,OMC,0,Performance Result Loss,Internal,Critical,2012/7/24 19:38:45 GMT+02:00 DST,"Cause=The performance result is missing.,
NE=SMSH1,
MU=956301762,
Time Segment=[2012-07-24 18:45:00 DST~2012-07-24 19:00:00 DST]",,,,,407,,,"FDN=.3221229568.3221278720.3221291131,


NE=SMSH1,
MU=956301759,
Time Segment=[2012-07-24 18:45:00 DST~2012-07-24 19:00:00 DST]",,,,,407,,,"FDN=.3221229568.3221278720.3221291131,
Period=15 min,
must be in the same line please help me as soon as possible!!!


See More: i need to remove \n but i have to do it just for 4 lines

Report •


#1
August 7, 2012 at 17:23:12
@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (funky.log) do (
set test=%%a
set test=!test:~0,3!
if "!test!" equ "NE=" set flag4lines=1
if flag4lines geq 1 (set bild4=!bild4!%%a) else (>> fixed.log echo %%a)
if flag4lines equ 4 (
>> fixed.log echo !bild4!
set flag4lines=0
)
)
goto :eof

:end
not tested.
None of my business, but yech! whatever generates this log sure has poor syntax etiquette. unmatchedt quotes all over the place. Not to mention your current problem with newlines. Whoever coded that, well, they need to go back to school in my book. (not you, the software mfr who mfr'd this output.) Oh well, hope it works.


Report •

#2
August 7, 2012 at 23:57:37
It coded by machine automaticly ; your code didn't worked =(

exeptions:
line 2: `for /f "tokens=*" %%a in (funky.log) do ('
line 2: syntax error near unexpected token `"tokens=*"'
line 1: setlocal: command not found
line 1: cecho off command not found


Report •

#3
August 8, 2012 at 17:32:51
No clue about line 2, unless it's a "seven" thing (i test on xp). Never had a problem here, with "tokens=*"
line 1, is: "cecho off" a typo in your response? should be "@" ("@echo off & setlocal")
but that still should not disable the setlocal command.
It's either a "seven" issue, or a local environment restrictions issue. I'll try to follow up with testing on simple win-7 machine.

Report •

Related Solutions


Ask Question