PHP code example of tranquilo / parsecsv

1. Go to this page and download the library: Download tranquilo/parsecsv library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tranquilo / parsecsv example snippets




ranquilo\ParseCsv;
///use Tranquilo\Exceptions\CsvException;

try{
	// filepath, delimiter : optional
	$csv = new ParseCsv(__DIR__ . '/test.csv', ","); 
	
	// optional convert the encoding
	$csv->convertEncoding('UTF-8');

	// // starts from 5 
	$withOffset = $csv->getWithOffset(5); 

	// gets all rows
	$allRowsCsv = $csv->get(5);

	// gets 10 rows starting from 5
	$withLimitAndOffset = $csv->get(5, 2);

	print_r($allRowsCsv);

	unset($csv);
	
}catch(CsvException $e){

	echo $e->getMessage();
	
}catch(Exception $e){

	echo $e->getMessage();
	
}