|
Posted by Geoff Berrow on 12/20/06 00:56
Message-ID: <1166568140.013219.144440@f1g2000cwa.googlegroups.com> from
larry@portcommodore.com contained the following:
>RATE - FAM2 -FAM3 - FAM4 - FAM5
>100 - 1200 - 1300 - 1375 - 1380
>123 - 1220 - 1320 - 1387 - 1392
>143 - 1242 - 1342 - 1400 - 1412
>
>So if it were a family of 3 with 1322 the rate would be 123.
>
>To make this into a DB for lookup is a cinch, but for someone to
>enter/update this compact table into a lookup DB is a pain.
>
>Is there any libraries out there already to read a text file like the
>above (more likely CSV) or a similarly formatted spreadsheet, or one
>that presents a table entry method to expidite the entry of a table
>like this?
You can do it with a simple loop. Let's say the data was in a file
called data.txt like so:
100,1200,1300,1375,1380
123,1220,1320,1387,1392
143,1242,1342,1400,1412
Then you just need something like:
<?php
//db connect goes here
$data=file('data.txt');
foreach ($data as $value){
$line=str_replace(",","','",$value);
$sql="INSERT INTO table VALUES('$line')";
mysql_query($sql);
}
?>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Navigation:
[Reply to this message]
|