PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of Sergii Pryz   PHP Split CSV   Example.php   Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Split CSV
Split CSV files input multiple parts set by rules
Author: By
Last change: Updated comment in Example.php.
Date: 10 years ago
Size: 803 bytes


Class file image Download
 * =====================================
 * Example of usage SplitCSV
 * =====================================

namespace SplitCSV;

// Autoload
require_once ('./src/Autoload.php');

// create File obj
$path = './tests/data/';
$source_path = $path.'test-10000-rows-357kb.csv';
$destination_path = $path.'parts';

$split = new File($source_path, $destination_path);

// choose rule "FileSize".
$rule = new Rule\FileSize(array('size' => '100kb'));
// example of other rule
// $rule = new Rule\NumberRow(array('number_row' => 10));

// split file by rule
$result = $split->splitBy($rule);

'File: "'.$source_path.'" has been successfully splitted by '.$result.' parts. Those files are avalable at location "'.$destination_path.'"';