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@
price=15
songs:
track=1
title=Michelle
track=2
title=Taxman
track=3
title=Tomorrow Never Knows
@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
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@"
--
Derek Sivers, CD Baby
[EMAIL PROTECTED] (503)595-3000
www.cdbaby.com | www.cdbaby.net
---------------------------------------------------------------------
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