Download the PHP package byjg/anydataset-text without Composer
On this page you can find all versions of the php package byjg/anydataset-text. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download byjg/anydataset-text
More information about byjg/anydataset-text
Files in byjg/anydataset-text
Package anydataset-text
Short Description Anydataset Text File abstraction. Anydataset is an agnostic data source abstraction layer in PHP.
License MIT
Informations about the package anydataset-text
AnyDataset-Text
Text file abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.
See more about Anydataset here.
Examples
Text File Delimited (CSV)
This type of files uses a delimiter to define each field. The most common formart is CSV but you can use your own based on a regular expression. The class TextFileIterator has three constants with pre-defined formats:
- TextFileDataset::CSVFILE - A generic file definition. It accept both
,
and;
as delimiter. - TextFileDataset::CSVFILE_COMMA - The CSV file. It accept only
,
as delimiter.- TextFileDataset::CSVFILE_SEMICOLON - A CSV variation. It accept only
;
as delimiter.
- TextFileDataset::CSVFILE_SEMICOLON - A CSV variation. It accept only
example1.csv
example1.php
Text File Delimited (CSV) - Get field names from first line
example2.csv
example2.php
Text File Fixed sized columns
This file has the field defined by it position on the line. It is necessary to define the name, type, position and field length for each field to to parse the file. This definition also allows set up required values and sub-types based on a value.
The field definition is created by the enum FixedTextDefinition
and it has the following fields:
Example:
Text File Fixed sized columns with conditional type of fields
Read from remote url
Both TextFileDataset
and FixedTextFileDataset
support read file from remote http or https
Formatters
This package implements two formatters:
- CSVFormatter - output the content as CSV File (field delimited)
- FixedSizeColumnFormatter - output the content with columns defined by length.
Click here for more information about formatters.