PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.2k forks source link

Read CSV File #1250

Closed kevingatp closed 7 years ago

kevingatp commented 7 years ago

Does this lib can read data from CSV file, I've tried and successfully upload the file, but there's a problem when read and convert the data into array. If it possible, how's the code? Thanks

felipph commented 7 years ago

This library has no intention to do such think. It's easy:

$arq = file("PATH TO YOUR FILE");

            $csv = array_map(function($v) {
                $v = trim($v);    
                return str_getcsv($v, ","); //REPLACE comma with your separator(In PT_BR is semicollon (;)
            }, $arq);
print_r($csv);

Regards.

PowerKiKi commented 7 years ago

Actually, yes it can: https://github.com/PHPOffice/PHPExcel/blob/1.8/Documentation/markdown/Overview/10-Reading-and-Writing.md#reading-a-csv-file