Page 1 of 1

[SOLVED] software to extract data from multiple text files

Posted: Mon Oct 04, 2010 2:25 pm
by hansencomputers
Greetings,
Can anyone point me to some software that will extract data from multiple text files?

What I have are multiple text files (.txt) and each one has some data in the same location. This data consists of text plus a number IE. "Passed 36"

All the text files will have this text and number (the number will vary) in the same location, as in the same line.

Ultimately, I want to sum all the parts that "passed" to get a grand total. My test equipment generates a text file after every test run, and includes the number of parts that passed.

I'm just wondering if there is software available to work with these multiple (maybe thousands) of text files, and get the number from a specific line, and sum it up (if I can just get all the numbers, I can use a spreadsheet to get the sum).

As always, any guidance is greatly appreciated.

Sincerely,
Mike Hansen

Re: software to extract data from multiple text files

Posted: Mon Oct 04, 2010 8:43 pm
by unexistance
Hi,

Frankly said, this looks like a solution for a script (non-GUI software) ...

Are you OK with that?

Regards,

Re: software to extract data from multiple text files

Posted: Tue Oct 05, 2010 5:19 am
by DataMan
It should be easy to accomplish in any of the supported programming languages.

I can help in php, but that means that you will need to have an active LAMP server up and running first. Probably more effort than it's worth.

Stay tuned as someone versed in python, c++ or bash using a regular statement may chime in for an easier solution.

-DataMan

Re: software to extract data from multiple text files

Posted: Tue Oct 05, 2010 5:52 am
by markfiend
grep seems to be what you are looking for.

Open a terminal, navigate to the folder with all your text files and

Code: Select all

grep Passed *.txt
You can pass the output into another file like this:

Code: Select all

grep Passed *.txt > output.txt
Your output.txt will contain all lines from the source files which include the word "Passed". It doesn't need to know which line "Passed" appears in.

Re: software to extract data from multiple text files

Posted: Tue Oct 05, 2010 8:44 am
by hansencomputers
Thanks everyone. I will look at the grep option. I'm at work right now, running Windoze. Will need to bring my laptop in to try this.

Answer to one of the questions: I don't mind if it is not a GUI program, but I may need guidance to get started. I have some limited programming experience with VB.NET, and also I use VBA here at work (Excel).


I will comment again if the grep option works for me.


Mike

[SOLVED] Re: software to extract data from multiple text fil

Posted: Wed Oct 06, 2010 11:00 am
by hansencomputers
The suggestion to use "grep" worked great. Problem solved. I have what I need.

Thanks,
Mike