2017 © Pedro Peláez
 

library csvfilehandler

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

image

daleattree/csvfilehandler

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  • Monday, January 11, 2016
  • by daleattree
  • Repository
  • 2 Watchers
  • 1 Stars
  • 2,140 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 12 Versions
  • 9 % Grown

The README.md

CSV File Handler (CsvFileHandler)

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object (License: GPL-2.0), (*1)

Installation

Included in a PHP Project w/ Composer

Add the following to your composer.json file using the latest version number or 1.0.* to keep it fresh:, (*2)

"require": {
  "daleattree/csvfilehandler": "1.0.*"
}

Usage

$csvFileHandler = new daleattree\CsvFileHandler\CsvFileHandler($filename, [$headerRow = true], [$delimiter = ','], [$enclosure = '"'], [$escape = '\\'], [$autoParse = true]);

Example

CSV File Content

id,greeting1,greeting2,salutation
1,"Regards, Test",hello,"there"

Code

foreach($csvFileHandler->getRecords() as $record){
  echo $record->getId() . PHP_EOL . 
  $record->getGreeting2()() . ' ' . $record->getSalutation() . PHP_EOL . 
  $record->getGreeting1() . PHP_EOL;
}

If the CSV file is too large for it to be efficiently loaded into memory, you can set $autoParse to false and read one line at a time from the file., (*3)

while(false !== ($row = $this->handler->readRecord())){
    //do something
}

Output

1
hello there
Regards, Test

If there is a header row, the column names will be camel-cased and accessible on RecordObject via get[ColumnName] and set[ColumnName] If there is no header row, column names default to col[n], n being the column index (zero-based)., (*4)

The Versions

11/01 2016

dev-master

9999999-dev

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.10

1.0.10.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.11

1.0.11.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.12

1.0.12.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.7

1.0.7.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.8

1.0.8.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

11/01 2016

1.0.9

1.0.9.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

04/10 2015

1.0.0

1.0.0.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

04/10 2015

1.0.1

1.0.1.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

04/10 2015

1.0.2

1.0.2.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

04/10 2015

1.0.3

1.0.3.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

04/10 2015

1.0.6

1.0.6.0

A library that loads and parses a CSV file, returning an object of the file with each CSV line as an object

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.3

 

The Development Requires