matrixpro/csv-delimiter-finder

Finds the delimiter in CSV files.

dev-master 2019-03-05 23:32 UTC

This package is auto-updated.

Last update: 2025-05-06 13:14:22 UTC


README

License

Automatically detects the delimiter type in a CSV file. Compatible with large CSV datasets (tested on 4gb+ files).

Install via composer:

composer require matrixpro/csv-delimiter-finder

Usage

Usage is simple: Simply pass a CSV file handle to the finder and use the findDelimiter() method. Will return FALSE if no valid delimiter is found.

$handle = fopen('path/to/file.csv', "r");
$finder = new CsvDelimiterFinder($handle);
$delimiter = $finder->findDelimiter();

You may optionally override the default set of delimiters that it checks for by using the setDelimiters() method:

$custom_delimiters = [',',';','|',"\t"];
$finder->setDelimiters($custom_delimiters);