0
Import csv to sql explode issue
I have managed to figure out that will work with array. I still haven't sort it but I'll put my code here, maybe you can help me. <?php function csv_to_array($filename='', $delimiter=',') { if(!file_exists($filename) || !is_readable($filename)) return FALSE; $header = NULL; $data = array(); if (($handle = fopen($filename, 'r')) !== FALSE) { while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) { if(!$header) $header = $row; else $data[] = array_combine($header, $row); } fclose($handle)
3 ответов
+ 5
Thats it, it has only the coma to delimit each cell if information also called a field.To understand it best, Load a csv in Notepad and you will see a bunch of commas. At the end the Notepad will insert an EOF character when you save the file. (End Of File)
Every row is a record of that file. So a CSV file is a database file in its simplistic form so it can be incorporated into any application you want. See it as a spreadsheet to comprehend it better.
+ 4
A CSV file is actually nothing then database. A CR marks the end of an record and a comma the end of a field of that record.
The information or the fields of a database in a CSV file are separated by a comma. Hence the name of CSV acronym is Comma Separated View.
You could read the file into a spreadsheet or use a database like Access from Microsoft.
Convert it into whatever you need to work with the information available. Each comma marks the end of a field of the record. The EOF code marks the end of the database
+ 1
can't figure out the delimitator other than just come