Download the PHP package atk14/csv-reader without Composer

On this page you can find all versions of the php package atk14/csv-reader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package csv-reader

CsvReader

Build Status

Reads CSV data from a file or a string. Detects automatically CSV format parameters.

Basic usage

$csv_data = '
k1;k2;k3
v1;v2;v3
x1;x2;x3
y1;y2
z1
';
$csv_data = trim($csv_data);

$reader = CsvReader::FromData($csv_data);
// or
$reader = CsvReader::FromFile("path/to/file.csv");

$reader->getRowCount(); // 5
$reader->getColumnCount(); // 3

$rows = $reader->getRows();
// [
//  ["k1","k2","k3"],
//  ["v1","v2","v3"],
//  ["x1","x2","x3"],
//  ["y1","y2",""],
//  ["z1","",""],
// ]

$rows = $reader->getRows(["offset" => 2]);
// [
//  ["x1","x2","x3"],
//  ["y1","y2",""],
//  ["z1","",""],
// ]

$row = $reader->getRow(0);
// ["k1","k2","k3"]

$row = $reader->getRow(1);
// ["v1","v2","v3"]

$col = $reader->getColumn(0);
// ["k1","v1","x1","y1","z1"],

$col = $reader->getColumn(0,["offset" => 1]);
// ["v1","x1","y1","z1"],

$col = $reader->getColumn(2);
// ["k3","v3","x3","",""],

$col = $reader->getColumn(3);
// []

$rows = $reader->getAssociativeRows();
// [
//  ["k1" => "v1", "k1" => "v2", "k3" => "v3"],
//  ["k1" => "x1", "k1" => "x2", "k3" => "x3"],
//  ["k1" => "y1", "k1" => "y2", "k3" => ""],
//  ["k1" => "z1", "k1" => "", "k3" => ""],
// ]

$rows = $reader->getAssociativeRows(["header_line" => 1]); // counting from 0, so this is the 2nd line
// [
//  ["v1" => "x1", "v1" => "x2", "v3" => "x3"],
//  ["v1" => "y1", "v1" => "y2", "v3" => ""],
//  ["v1" => "z1", "v1" => "", "v3" => ""],
// ]

$rows = $reader->getAssociativeRows(["keys" => ["f1","f2","f3"]]);
// [
//  ["f1" => "k1", "k1" => "k2", "k3" => "k3"],
//  ["f1" => "v1", "k1" => "v2", "k3" => "v3"],
//  ["f1" => "x1", "k1" => "x2", "k3" => "x3"],
//  ["f1" => "y1", "k1" => "y2", "k3" => ""],
//  ["f1" => "z1", "k1" => "", "k3" => ""],
// ]

$rows = $reader->getAssociativeRows(["keys" => ["f1","f2","f3"], "offset" => 2]);
// [
//  ["f1" => "x1", "k1" => "x2", "k3" => "x3"],
//  ["f1" => "y1", "k1" => "y2", "k3" => ""],
//  ["f1" => "z1", "k1" => "", "k3" => ""],
// ]

CSV format parameters auto-detection

The CsvReader detects format parameters automatically. If the auto-detection fails, format parameters can be specified explicitly.

$reader = CsvReader::FromData($csv_data,[
  "delimiter" => ";",
  "quote" => "'"
]);
// or
$reader = CsvReader::FromFile("path/to/file.csv",[
  "delimiter" => ";",
  "quote" => "'"
]);

Installation

composer require atk14/cvs-reader

Testing

composer update --dev
./vendor/bin/run_unit_tests test

License

CsvReader is free software distributed under the terms of the MIT license


All versions of csv-reader with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atk14/csv-reader contains the following files

Loading the files please wait ....