Monday, April 29, 2013

Read and parse csv file using php code

Details http://code.google.com/p/parsecsv-for-php/
Or download from here

Use:

require_once('../parsecsv.lib.php');
# create new parseCSV object.
$csv = new parseCSV();
# Parse '_books.csv' using automatic delimiter detection...

$csv->conditions = 'author does not contain dan brown';
$csv->conditions = 'rating < 4 OR author is John Twelve Hawks';
$csv->conditions = 'rating > 4 AND author is Dan Brown';

$csv->sort_by = 'title';

# offset from the beginning of the file,
# ignoring the first X number of rows.
$csv->offset = 2;

# limit the number of returned rows.
$csv->limit = 3;

$csv->auto('_books.csv');

foreach ($csv->titles as $value);
foreach ($csv->data as $key => $row);

No comments:

Post a Comment