Skip to content

Infer CSV delimiter if it hasn't been set explicitly#141

Closed
lanthaler wants to merge 4 commits intoPHPOffice:developfrom
lanthaler:infer-delimiter
Closed

Infer CSV delimiter if it hasn't been set explicitly#141
lanthaler wants to merge 4 commits intoPHPOffice:developfrom
lanthaler:infer-delimiter

Conversation

@lanthaler
Copy link
Contributor

This change tries to infer the delimiter if it hasn't been explicitly set. It first counts the number of occurrences of a number of potential delimiters (max. first 1000 lines) of a CSV file and then chooses the one which occurs most regularly (mean square deviation).

@PowerKiKi
Copy link
Member

Looks good to me, but we miss unit tests to be merged. Could you please add some, most likely in PhpOffice\PhpSpreadsheetTests\Reader\CsvTest and if you need CSV files maybe put them in tests/data/Reader/Csv ?

@PowerKiKi PowerKiKi added the reader/csv Reader for CSV files label Apr 18, 2017
@lanthaler
Copy link
Contributor Author

@PowerKiKi, thanks. I added a test.

@PowerKiKi PowerKiKi closed this in 3ee9cc5 Apr 20, 2017
@PowerKiKi
Copy link
Member

Thanks for your contribution !

I added a bit of documentation and changelog and merged everything as a squashed commit.

BlackyTay pushed a commit to BlackyTay/PhpSpreadsheet that referenced this pull request Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reader/csv Reader for CSV files

Development

Successfully merging this pull request may close these issues.

2 participants