Download the PHP package wilgucki/php-csv without Composer

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

PHP-CSV

PHP-CSV is a package that allows you to manage CSV files in an object-oriented way.

Installation

There's not much to do, just run this composer command

Usage

Both, Reader and Writer classes are easy to use. In fact the classes are just a wrappers for built-in PHP functions.

Reader

Reader class will help you with reading existing CSV files (no surprise here).

To read CSV file you need to open it first.

Constructor accepts optional arguments you can use to describe your CSV file. The arguments are:

First three arguments are exactly the same as fgetcsv function arguments described in the manual - http://php.net/manual/en/function.fgetcsv.php

Other two helps you define encoding - $encodingFrom is the encoding of CSV file and $encodingTo is encoding we get after file is read.

To read data from the CSV file we can use two functions: readLine and readAll. The former will read and return current row while the latter will read whole CSV file and return it as an array of arrays (each line will be represented by an array).

If the CSV file has a header row, you can use getHeader function. This function will take the first row from CSV file and use it to set array keys for readLine and readAll functions. This means that instead of numeric keys you can use labels defined in the first row.

Converters

Sometimes data available in csv file need to be converterd into more suitable format, e.g. convert dates into Carbon objects. Converters make this task much easier. All you need to do is to create converter object and specify the column you want to convert.

You can assigon only one converter per column.

Examples

CSV file example

Don't forget to close CSV file after you are done.

Writer

For creating/updating CSV files you can use Writer class. If you want to create file, you need to provide only a writable path. For updating existing file, you have to use optional $mode argument. All available modes are described in the manual (https://secure.php.net/manual/en/function.fopen.php) but only 'w' and 'a' values are usable in this case.

Writer contructor accepts the same arguments as the Reader constructor. Only difference is that $encodingFrom refers to the input encoding and the $encodingTo refers to CSV file encoding.

There are two ways of writing CSV files - writeLine and writeAll. First method will write a single line to a CSV file, while the second method will write multiple lines. If for some reason you need to access data you have written to a CSV file you can use flush method.

Examples

Don't forget to close CSV file after you are done.

TODO


All versions of php-csv with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
nesbot/carbon Version ^2.17
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 wilgucki/php-csv contains the following files

Loading the files please wait ....