Moving elements to end of previous line
I have a problem with moving a defined text block ("PT") to the end of its previous line.. for eg, consider the following :-
100001,-6.0704
PT 100061,19.1127 100122,8.1831 PT
I need that to be :-
100001,-6.0704PT
100061,19.1127 100122,8.1831PT
I have a large irregularly repeating data like this开发者_Go百科.. and need to achieve this..(moving the "PT" to currentline-1")
I have Notepad++ I need to achieve this somehow.. maybe using spreadsheets? online tools? and how? macros? batch files?
try this as a first attempt
@echo off
setlocal enabledelayedexpansion
set prevline=
for /f "tokens=*" %%a in (a.txt) do (
if '%%a'=='PT' (
echo !prevline!PT
set prevline=
) else (
if not '!prevline!'=='' echo !prevline!
set prevline=%%a
)
)
this batch file iterates over all the lines of the a.txt file, storing each line in the variable prevline
, if it happens to find the 'PT' string it spits the stored line and concatenates the PT, if it happens not to find the PT string, it spits just the stored line and stores the new line.
For a further explanation, see help for
and help set
.
精彩评论