PROJECT: for perl/sed/regex type...

2001-01-25 Thread Derek Sivers

I've got a quickie project here, that's over my head, that I could pay a little 
something for:


Can you set up a script that will take flat text files, (one file per record, many 
files per directory) - and do some sed/regex conditional replace, and turn it into 
MySQL statements?

I've done one, below, but don't know how to automate the process.

TIMELINE: by this weekend, January 27
PAYPOINT: $100 (done as a perl, shell, or PHP script that can scan a set directory 
for incoming text files, run your process on each one, then feed each one into MySQL.)

- INCOMING FILE: 

name=John Jacob Schmidt
addr=1313 Willamena Way
username=asdfhjkl
artistname=The Beatles
albumname=Can't Get Enough
description:
One of the best albums they ever made.
Really one of the finest.
Oh yes i mean it truly.
@END@END@
price=15
songs:
track=1
title=Michelle
track=2
title=Taxman
track=3
title=Tomorrow Never Knows
@END@END@

- OUTGOING FILE: 
insert into clientinfo (
name='John Jacob Schmidt',
addr='1313 Willamena Way',
username='asdfhjkl');

insert into albuminfo (
albumcode=concat('username', now()),
artistname='The Beatles',
albumname='Can\'t Get Enough',
description='One of the best albums they ever made.
Really one of the finest.
Oh yes i mean it truly.',
price='15');

insert into songs (
albumcode='$albumcode',  // the auto-generated one we used in the previous table
track='1',
title='Michelle')
insert into songs (
albumcode='$albumcode',
track='2',
title='Taxman');
insert into songs (
albumcode='$albumcode',
track='3',
title='Tomorrow Never Knows');


NOTE: Most fields are only one line, so the carriage return is the stopping point. 
But as you see there are just a few that have carriage returns, so on those we do 
"fieldname:" instead of "fieldname=" - then end it with "@END@END@"

More details if you're interested, but that's about it.  The actual file is twice as 
big, but with no other surprises.  (That's an actual example, above, just with some 
lines taken out.).
Please reply by email, not to the whole list.
Thanks!

-- 
Derek Sivers
[EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: PROJECT: for perl/sed/regex type...

2001-01-25 Thread Colin Faber

see LDIF parsing.


Derek Sivers wrote:

 I've got a quickie project here, that's over my head, that I could pay a little 
something for:

 Can you set up a script that will take flat text files, (one file per record, many 
files per directory) - and do some sed/regex conditional replace, and turn it into 
MySQL statements?

 I've done one, below, but don't know how to automate the process.

 TIMELINE:  by this weekend, January 27
 PAYPOINT:  $100  (done as a perl, shell, or PHP script that can scan a set directory 
for incoming text files, run your process on each one, then feed each one into MySQL.)

 - INCOMING FILE: 

 name=John Jacob Schmidt
 addr=1313 Willamena Way
 username=asdfhjkl
 artistname=The Beatles
 albumname=Can't Get Enough
 description:
 One of the best albums they ever made.
 Really one of the finest.
 Oh yes i mean it truly.
 @END@END@
 price=15
 songs:
 track=1
 title=Michelle
 track=2
 title=Taxman
 track=3
 title=Tomorrow Never Knows
 @END@END@

 - OUTGOING FILE: 
 insert into clientinfo (
 name='John Jacob Schmidt',
 addr='1313 Willamena Way',
 username='asdfhjkl');

 insert into albuminfo (
 albumcode=concat('username', now()),
 artistname='The Beatles',
 albumname='Can\'t Get Enough',
 description='One of the best albums they ever made.
 Really one of the finest.
 Oh yes i mean it truly.',
 price='15');

 insert into songs (
 albumcode='$albumcode',   // the auto-generated one we used in the previous table
 track='1',
 title='Michelle')
 insert into songs (
 albumcode='$albumcode',
 track='2',
 title='Taxman');
 insert into songs (
 albumcode='$albumcode',
 track='3',
 title='Tomorrow Never Knows');

 NOTE:  Most fields are only one line, so the carriage return is the stopping point.  
But as you see there are just a few that have carriage returns, so on those we do 
"fieldname:" instead of "fieldname=" - then end it with "@END@END@"

 More details if you're interested, but that's about it.  The actual file is twice as 
big, but with no other surprises.  (That's an actual example, above, just with some 
lines taken out.).
 Please reply by email, not to the whole list.
 Thanks!

 --
 Derek Sivers
 [EMAIL PROTECTED]

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php