Extact info from lines containing x text

October 17, 2009 at 06:28:31
Specs: Windows XP
Honestly I'm new to programming, and I'm needing some help with something I'm working on. And honestly the files I'm grabbing from isn't helping me.
The first problem is information I'm trying to extract from the log files needs to be extracted from the bottom up and stop looking at say the word stop.
Secondly some of the log files have more than one instance of the information and it needs to be processed seperately, and then the file needs to be saved with the day before's date.
so the info goes kinda like this
245.04,756.23,test
345.74.123.87,test2
123.99,123.56,test3
I'm looking to extract the information from the second group of numbers, and the problem is sometimes the test2 line might not be there. So I want to get a value of 0 put if it's not there.
Any help would be greatly appreciated.

See More: Extact info from lines containing x text

Report •


#1
October 17, 2009 at 08:58:01
Reverse sort the file or load in a database so it can be scanned line by line from rear.

Report •

#2
October 17, 2009 at 11:23:47
You need to be clear about the rules for extraction.


=====================================
Helping others achieve escape felicity

M2


Report •

#3
October 17, 2009 at 11:41:16
Sorry that I forgot a couple of important parts
This is off a text file that I can't really alter.

The rules of extraction would be basically be.

245.04,756.23,test
345.74.123.87,test2
123.99,123.56,test4

Look for test, test2, test3, test4 extract data. If data for anything looked for isn't present enter 0 so that extracted would come out like
756.23
123.87
0
123.56

Thank you


Report •

Related Solutions

#4
October 17, 2009 at 19:29:52
@echo off > newfile & setLocal enableDELAYedexpansion

set N=

for /f "tokens=* delims= " %%a in (datafile) do (
set /a N+=1
if !N! equ 1 (
> mydata echo %%a1
) else (
>> mydata echo %%a
)
)

set N=
set X=

for /f "tokens=3 delims=," %%a in (mydata) do (
set str=%%a
set X=!str:test=!
)

for /L %%i in (1 1 !X!) do (
set /a N+=1
set data=0
for /f "tokens=2-3 delims=," %%d in (mydata) do (
if %%e equ test!N! (
set data=%%d
)
)
>> newfile echo !data!
)


=====================================
Helping others achieve escape felicity

M2


Report •


Ask Question