|
Posted by Tyrone Slothrop on 11/24/05 03:30
On Wed, 23 Nov 2005 23:15:24 GMT, "Jon"
<jon@thisisafakeaddressignoreit.com> wrote:
>Hi,
>
>I have a csv file which contains rows with the following fields:
>
>category1,category2,category3,data1,data2,data3
>
>What is the simplest way to parse the rows?
>
>I'd like to count the number of category2's per item in category3. Number
>of category3's per category2 item etc...
>
>I know this could be done with a database, but I don't have a database on my
>server.
>
>Kind Regards,
>
>Jon.
>
One way to do it:
$data = file ("file.csv");
foreach ($data as $line)
{
list (category1,category2,category3,data1,data2,data3) = split(',',
$line);
}
Or, if you want to treat as an array:
foreach ($data as $line)
{
$record[] = explode(',', $line);
}
[Back to original message]
|