Re: Very interesting and challenging question

From: Date: Wed, 28 Nov 2001 17:09:18 +0000
Subject: Re: Very interesting and challenging question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75903@lists.php.net to get a copy of this message
I had something like this to do a couple of months back, unfortunately, my code was deleted by someone "smart" in my office. But i can pretty much remember the algorithim behind it. What I done was read in my file into a buffer, then use the explode function, i think, or something like it, basicially there is a function that allows you to parse a string using a set number of char as the delimiters, e.g. first item = first 10 chars etc, i think i was able to differentiate the number of chars, e.g. 10 for the first item, maybe 15 for the second and so on. I then read them all into an arry. once in the array it's a piece of cake, I know which item in the array corresponds to which field from the original file, e.g. item 1 = row 1 col 1, item 2 = row 1 col 2, item 5 = row 2 col 1 (assuming there are 4 cols). At this point you can just loop through the array inserting the fields into the database, or whatever you want to do. I cant remember what happens when I had empty fields. I think I may have had to fill in all blank fields for some reason. I'm not sure if this makes any sense. But I hope it's been a help. Conor On Wed, Nov 28, 2001 at 09:01:26AM -0800, Dan McCullough wrote: > I need to take a file, similar to this and strip it of everything but this, and write it to a > database. Are there any thoughts on how to get the information out, all the files are > consistent. > <!-- start strip --> > Race Final Watkins Glen International > 2.450 miles 31 laps > -------------------------------------------------------------------------------- > Fin Str Driver Laps Led Pts Qual Reason Out > -------------------------------------------------------------------------------- > <!-- end strip --> > <!-- start output --> > 1 2 18 Dynamike18 31 24 185 118.007 Running > 2 7 68 jcordeiro 31 0 170 116.078 Running > 3 5 80 MattyJ140 31 0 165 116.881 Running > 4 1 28 RUDD#28 31 6 165 118.219 Running > 5 13 57 1SpeedDemon 31 0 155 Running > 6 9 84 legends3 31 1 155 115.131 Running > 7 3 56 RobertFx3D 31 0 146 117.854 Running > 8 12 55 24skids 31 0 142 98.644 Running > 9 4 53 Mark_O_10 31 0 138 117.323 Running > 10 8 91 JJinsane 31 0 134 116.061 Running > 11 10 8 beertipper 31 0 130 114.154 Running > 12 11 44 Wis>OutLaw 10 0 127 111.022 DNF > 13 6 51 BdgrOtlw 3 0 124 116.702 DNF > <!-- End 1st output --> > > <!-- Start second output --> > > > Race time - 72:52.030 > > Average speed - 62.538mph > > Margin of victory - 1.944sec > > Caution flags - 7 > > # of lead changes - 3 > > Weather - Clear 70^ E 0mph > <!-- End second output --> > > thanks for any help > > > ===== > Dan McCullough > ------------------------------------------------------------------- > "Theres no such thing as a problem unless the servers are on fire!" > h: 603.444.9808 > w: McCullough Family > w: At Work > > __________________________________________________ > Do You Yahoo!? > Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. > http://geocities.yahoo.com/ps/info1 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#75903) next »