parsecsv / parsecsv-for-php

CSV data parser for PHP.
MIT License
678 stars 176 forks source link

skip empty rows #170

Closed osc2nuke closed 5 years ago

osc2nuke commented 5 years ago

Not sure if it is already asked or supported. I have a supplier that delivers csv with a blank line between each row. Is there a way to skip these? As it count's them in as an entry.

osc2nuke commented 5 years ago

Perhaps not desirable: https://github.com/parsecsv/parsecsv-for-php/blob/b746ea1de0f5a73e9dae1f184b8a975759655f1c/src/Csv.php#L1173

right below: https://github.com/parsecsv/parsecsv-for-php/blob/b746ea1de0f5a73e9dae1f184b8a975759655f1c/src/Csv.php#L1175

Add: $data = preg_replace("![\n\r]+\s*[\n\r]+!", "\r\n", $data);