The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started


Inserting Records

Selecting Records

Converting Records

Upgrading Guide

This is the documentation for the upcoming version 9.0. This is a work in progress

Document interoperability

Depending on your operating system and on the software you are using to read/import your CSV you may need to adjust the encoding character and add its corresponding BOM character to your CSV.

Out of the box, League\Csv assumes that your are using a UTF-8 encoded CSV.

In the examples below we will be using an existing CSV as a starting point. The code may vary if you are creating the CSV from scratch.

MS Excel on Windows

On Windows, MS Excel, expects an UTF-8 encoded CSV with its corresponding BOM character. To fullfill this requirement, you simply need to add the UTF-8 BOM character if needed as explained below:


use League\Csv\BOM;
use League\Csv\Reader;

$reader = Reader::createFromPath('/path/to/my/file.csv');
//BOM detected and adjusted for the output
echo $reader->__toString();

MS Excel on MacOS

On a MacOS system, MS Excel requires a CSV encoded in UTF-16 LE using the tab character as delimiter. Here’s an example on how to meet those requirements using the League\Csv package.


use League\Csv\BOM;
use League\Csv\Reader;
use League\Csv\Writer;

//the current CSV is ISO-8859-15 encoded with a ";" delimiter
$origin = Reader::createFromPath('/path/to/french.csv', 'r')

//let's use stream resource
//let's set the output BOM
//we set the tab as the delimiter character
$writer = Writer::createFromStream(fopen('php://temp', 'r+'))

//we insert csv data
//all is good let's output the results