General:
$csv = new parseCSV('data.csv');
print_r($csv->data);Tab delimited, and encoding conversion:
$csv = new parseCSV();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = "\t";
$csv->parse('data.tsv');
print_r($csv->data);Auto-detect delimiter character:
$csv = new parseCSV();
$csv->auto('data.csv');
print_r($csv->data);
Modify data in a CSV file:
$csv = new parseCSV();
$csv->sort_by = 'id';
$csv->parse('data.csv');
# "4" is the value of the "id" column of the CSV row
$csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com');
$csv->save();Add row/entry to end of CSV file:
Only recommended when you know the extact sctructure of the file.
$csv = new parseCSV();
$csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true);Convert 2D array to csv data and send headers to browser to treat output as a file and download it:
$csv = new parseCSV();
$csv->output (true, 'movies.csv', $array);
very goog
Thank you for this nice PHP class. It does all i want like expected...
Thanks so much for your work, and for generously putting this out there as opensource. I needed to do just this myself, and searched PEAR for a CSV parser, but was surprised to see none available. Thanks again!
Thanks!
Brilliant... Thankyou!
Thanks! Just nice!
This class saved my life :) A 1000 Thanks.
Amazing Class, Thank you for your hard work.
Nice work, thank you for sharing!
That 's an excellent library. I was really looking for that. God bless you!
Thanks
Can you reverse the order of the sort?
much appreciated
really good work! very impressive auto detection going on there! Isn't it great when something just works hey ;-)
Nice work
thanks !!!!!1
Goog Work, I use it on my Web site Insolite du Geek.
Thanks
thanks a lot !!!
superb! was able to convert a very slow api export to a csv file in minutes, making myself (and my client) very happy :D kudos!
You are my god My people shall worship thee for eons to come.
You can find the detailed information on http://www.phpkode.com
Thanks!
This code easily knocked 75% off the development time for the http://code.google.com/p/ofcom-csverter/ project.
I never would have figured out how to parse a CSV file while catering for a variety of separators and enclosures.
I had problems with the page, offset, limit
muchas gracias amigo!
thanx for this...may prove very useful
You should change function signatures. output():
$csvHeader = array('Car name', 'color'); $csvData = array( array('Ford', 'black'), array('Opel', 'red'), ); $csv = new parseCSV(); $csv->output('cars.csv', $csvData, $csvHeader, ',');Hmm, maybe because I have 0.4.3 beta.
I tried this example and it work but on save it create new empty row between my file rows and not any data are saved whyy?
Thank you :)