CSV Parsing using ParseCsv PHP class

Parse Csv

What is ParseCsv?

ParseCsv is an easy-to-use PHP class that reads and writes CSV data properly.

Where do I get ParseCsv?

CSV data parser for PHP can be aquired at the ParseCsv GitHub repository


Do I need to use ParseCsv?

You may not need a library at all. Before using ParseCsv, try using PHP's own functions to see if they meet your needs.


Installation is easy using Composer. Just run the following on the command line:

composer require parsecsv/php-parsecsv

You may have to manually include Composer's autoloader file in your PHP script:

require_once __DIR__ . '/vendor/autoload.php';


Without composer

Not recommended, but technically possible: you can also clone the repository or extract the ZIP. To use ParseCSV, you then have to add

require 'parsecsv.lib.php';

Example Usage


$csv = new ParseCsvCsv('data.csv');

Tab delimited, and encoding conversion

$csv = new ParseCsvCsv();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = "	";

Auto-detect delimiter character

$csv = new ParseCsvCsv();

Parse data with offset

  • ignoring the first X (e.g. two) rows
$csv = new ParseCsvCsv();
$csv->offset = 2;


  • ParseCsv is a complete and fully featured CSV solution for PHP
  • Supports enclosed values, enclosed commas, double quotes and new lines.
  • Automatic delimiter character detection.
  • Sort data by specific fields/columns.
  • Easy data manipulation.
  • Basic SQL-like conditionsoffset and limit options for filtering data.
  • Error detection for incorrectly formatted input. It attempts to be intelligent, but can not be trusted 100% due to the structure of CSV, and how different programs like Excel for example outputs CSV data.
  • Support for character encoding conversion using PHP's iconv() and mb_convert_encoding() functions.
  • Supports PHP 5.5 and higher. It certainly works with PHP 7.2 and all versions in between.

Source: https://github.com/parsecsv/parsecsv-for-php


Visit sunny St. George, Utah, USA