Download the PHP package luchaninov/csv-file-loader without Composer

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

CSV File Loader

Load CSV & TSV files and strings using PHP generators. It uses memory like fopen but requires less code.

How to Install

Install the luchaninov/csv-file-loader package using composer:

Basic Usage

If you have CSV-file

you'll get 2 items

It uses fgetcsv function so it understands enclosed values like

and even

If you have simple string, no need to save it to the file. Use

Advanced Usage

If file is not large you can load all items at once without generators using getItemsArray().

If you have custom delimiters use setDelimiter like $loader->setDelimiter(';'). Same with encloser - setEncloser. Default delimiter is , for CsvFileLoader and \t for TsvFileLoader; default encloser is ". If you are not sure - use delimiter auto, it detects delimiter automatically by the first 10,000 characters.

If you have TSV instead of CSV you can set use setDelimiter("\t") or use TsvFileLoader. If you are not sure - use AutoFileLoader, it detects delimiter automatically.

By default it assumes that the first row of the file contains headers - it doesn't return this row as item but uses as keys for next rows. If you don't have headers in the first row - you can:

If there are more cols in some rows than there are cols in headers then they are truncated. If you prefer to add extra values with numerical keys use setAddUnknownColumns(true).

To count items use countItems(). In case of CSV it's not always the same with rows count - wc -l, because one item can have several rows.

You can use same loader to load several files - $loader->setFilename('other_file.csv'). If you iterate during some file when calling setFilename then there will be no more items from the first file, foreach will just finish.

Code is very simple - look at sources and tests.

TxtFileLoader

If you have simple text file use TxtFileLoader.

It makes from file

array ['text1', 'text2', 'text3'].

setSkipEmptyRows

Skips empty rows or containing only whitespaces trim($s) === ''. Default: true.

setSkipComments

Skips rows that start with # or \s+#. Default: false.


All versions of csv-file-loader with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-mbstring Version *
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 luchaninov/csv-file-loader contains the following files

Loading the files please wait ....