MAMEWorld >> Programming
View all threads Index   Flat Mode Flat  

StilettoAdministrator
They're always after me Lucky ROMS!
Reged: 03/07/04
Posts: 6472
Send PM
Batch file processing...
03/29/07 08:12 AM


Okay, so on a work computer I have a file directory similar to this:

STATES
|_ ALABAMA
|_ ALASKA
.
.
.
|_ WYOMING


In each folder there are large numbers of "proprietary" binary files, with each file having large amounts of ASCII text inside. The file is named like so: DATA - CITY1.stl. In my example, this will be "Joe Smith - Detroit.stl"

The inside of a file would be similar to so:
...header...
"NAME"="Joe Smith"
"CITY2"="Detroit"
"PHONE"="3015551212"
"IMAGE"=encoded monochrome image
...other fields...
...footer...

I'd like a script/app that goes through the folder, including all subdirectories, extracts the DATA, CITY1, NAME, CITY2 and PHONE fields from each file, and concatenates it all into a CSV file where a sample CSV would look like so:

DATA,CITY1,NAME,CITY2,PHONE
Joe Smith,Detroit,Joe Smith,Detroit,3015551212

The character combination to parse the filename will always be " - ". That's right, whitespace-hyphen-whitespace.

grep should do the trick, as would a Perl script, but it's been a good decade since I've dealt with either.

Anyone kind enough to save me some time? Once I have the feel for it, I should be able to fill in the particular ASCII to hunt for, as far as file data goes, myself.

I _can_ do it myself, but it will just take longer that way. I have a feeling someone here should be able to code this without even realizing it.

For bonus points, insert another field in the CSV that displays "% similar" statistic in comparing CITY1 and CITY2 fields.

In return, you get a tasty pudding snack.

- Stiletto

Edited by Stiletto (03/29/07 08:47 AM)







Entire thread
Subject Posted by Posted on
* Batch file processing... StilettoAdministrator 03/29/07 08:12 AM
. * Re: Batch file processing... krick  03/29/07 08:58 PM
. * Re: Batch file processing... StilettoAdministrator  03/30/07 11:00 AM
. * Re: Batch file processing... krick  03/30/07 09:08 PM
. * Re: Batch file processing... StilettoAdministrator  03/31/07 09:48 AM
. * Re: Batch file processing... Anonymous  04/02/07 07:26 PM
. * Re: Batch file processing... StilettoAdministrator  04/03/07 08:03 AM
. * Re: Batch file processing... Anonymous  04/06/07 02:17 PM
. * Re: Batch file processing... StilettoAdministrator  04/07/07 07:56 AM
. * Re: Batch file processing... Anonymous  04/07/07 10:18 AM
. * Re: Batch file processing... StilettoAdministrator  04/11/07 09:45 AM
. * Re: Batch file processing... R. Belmont  04/16/07 05:48 PM

Extra information Permissions
Moderator:  Pi 
0 registered and 55 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 4015