Download the PHP package htmlburger/carbon-csv without Composer

On this page you can find all versions of the php package htmlburger/carbon-csv. 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 carbon-csv

Carbon CSV

Carbon CSV is a PHP library aimed at simplifying CSV parsing.

It provides simple interface to ease mapping columns via a header row, or custom column names.

Installation

Usage

Suppose that you have the following CSV:

First Name Last Name Company Name Address
Homer Simpson Springfield Nuclear Power Plant 742 Evergreen Terrace, Springfield
Ned Flanders The Leftorium 744 Evergreen Terrace, Springfield

Here is how you could iterate through the rows:

Would produce the following output:

Alternatively, you could also provide your own column names:

Would produce the following output:

MacOS encoding

When working with files created on a Mac device, you should set the auto_detect_line_endings PHP variable to 1.

Settings

To change the delimiter, enclosure and escape characters for the CSV file, simply pass them as arguments after the file path.

Example:

Methods

Methods for skipping rows or columns work with zero based indexes.

skip_to_row(int $row_index)

To skip to a specific row, simply pass the index of the row.

This will tell the parser to start reading from that row until the end of the file.

Contents before skipping to a specific row:

Contents after skipping to a specific row:

skip_to_column(int $col_index)

To skip to a specific column, simply pass the index of the column.

Contents before skipping to a specific column:

Contents after skipping to a specific column:

skip_columns(array $col_indexes)

To skip multiple columns, pass the indexes of those columns as an array.

Contents before skipping columns:

Contents after skipping columns:

use_first_row_as_header()

To use the first row from the CSV, simply call this method.

Note: if skip_to_row is called prior to calling use_first_row_as_header, the parser will use the new first row as a header.

Contents before assigning a header row:

Contents after assigning a header row:

Since we're telling the parser to use the first row as a header row, it is assigned and skipped.

set_column_names(array $columns_mapping)

If you wish to use your own indexes for the columns, pass them using an array.

Note: you can use set_column_names in conjunction with use_first_row_as_header, so you can set the names of the columns based on the header row.

Example without use_first_row_as_header (using a file without a head row):

Contents before setting custom column names:

Contents after setting custom column names:


Example with use_first_row_as_header (using a file with a head row):

Contents before setting custom column names:

Contents after setting custom column names:

set_encoding($encoding)

Set the encoding of the CSV file. This is needed, so it can be properly converted to utf-8

Example:

count()

Get the total number of rows in the CSV file (this skips the empty rows):

$total_number_of_rows = $csv->count() is equivalent to count($csv->to_array()).


All versions of carbon-csv with dependencies

PHP Build Version
Package Version
Requires php Version ^5.4.0 || ^7.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 htmlburger/carbon-csv contains the following files

Loading the files please wait ....