Download the PHP package godsgood33/csv-reader without Composer

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

CSV Reader

Intro

The purpose of this library is to simplify reading and parsing CSV files. I have parsed CSV files so many times and there is not really an easy way to do it. You have to know the index of the column you want to insert and it would be so much more readable if you could just use the header title itself as the field index. A while ago, I started reading the header row, flipping the array so that the index of the row elements is now the value of the field index.

This allows you the ability to use the header title as an index into the data array.

This is nice, but isn't any more readable than just using the index itself (or store the index in a variable and using that)...

So what I thought I would do is create a library that would allow you to use the header titles as field names. Here's how you do it.

Installation/Setup

Dev.to

I have done a more thorough explanation on Dev.to

Use

Pass your CSV filename into the class and create an object

Options

These options are available as an associative array as the second parameter of the constructor

The Reader will remove any non-alphanumeric characters [^a-zA-Z0-9_].

After this is done, all you need to do is start looping until the end of the file is reached or the data you're looking for is found.

NOTE: Reader will automatically read the first row after the header after it is done parsing so DON'T use a while loop

Inside your loop you can use the header titles as field names to retrieve the data at each column

Required Headers

If there are required headers that you must have in your file you can specify them in the 'required_headers' option passed in at instantiation time.

Aliases

If you would like to specify that a field has an alias name you can specify that with the 'alias' associative array option. The key parameter is the alias and the value is the field it points to.

The above would allow you to use the either of the following:

Maps

Full Explanation

Maps in CSVReader are a way that you can read multiple fields at once and return all of them in a formatted string.

Filters

Full Explanation

Filters can be a really powerful option when parsing a file. They can be used to validate the field values before ingesting them into the system, for manipulating the data, removing or adding characters, adding in other data so that it works better in a database or HTML, or creating an object from a field value. Filters can be used along with aliases, but you MUST do the filter on the field that is in the file...not the alias. In the example above, the filter would have to be assigned to the phone field and not digits. Filters do NOT work with Maps as those already include their own callback so the filter functionality can be accomplished in the Map callback.

Links

Full Explanation

Links are a way that you can retrieve multiple fields at the same time and return them as a stdClass object or create your own object.


All versions of csv-reader with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 godsgood33/csv-reader contains the following files

Loading the files please wait ...