PHPackages                             byjg/anydataset-text - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. byjg/anydataset-text

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

byjg/anydataset-text
====================

Text file abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.

6.0.0(7mo ago)45.8k↓26.5%1MITPHPPHP &gt;=8.3 &lt;8.6CI failing

Since Nov 24Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/byjg/php-anydataset-text)[ Packagist](https://packagist.org/packages/byjg/anydataset-text)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-anydataset-text/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (3)Versions (11)Used By (0)

   sidebar\_key anydataset-text   tags    php

 anydataset

 text-manipulation

    Text File Abstraction Dataset
=============================

[](#text-file-abstraction-dataset)

Text file abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-anydataset-text/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-anydataset-text/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-anydataset-text/)[![GitHub license](https://camo.githubusercontent.com/c05086ecff52823c8be312185afc989e10690be3101695ff97fa84cab341f4bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d616e79646174617365742d746578742e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/62da2160cf563befd3b51cfdff17dcb60e5515721ad1d4d00b625997576c8669/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d616e79646174617365742d746578742e737667)](https://github.com/byjg/php-anydataset-text/releases/)

See more about Anydataset [here](https://opensource.byjg.com/anydataset).

Features
--------

[](#features)

- Read and parse delimited text files (CSV, etc.)
- Read and parse fixed-width text files
- Support for remote files via HTTP/HTTPS
- Conditional field parsing based on field values
- Output formatting to CSV or fixed-width formats

Documentation
-------------

[](#documentation)

- [TextFileDataset](docs/TextFileDataset.md) - Work with delimited text files (CSV, etc.)
- [FixedTextFileDataset](docs/FixedTextFileDataset.md) - Work with fixed-width text files
- [FixedTextDefinition](docs/FixedTextDefinition.md) - Define the structure of fixed-width text files
- [Formatters](docs/Formatters.md) - Output dataset content in specific formats

Quick Examples
--------------

[](#quick-examples)

### Text File Delimited (CSV)

[](#text-file-delimited-csv)

This type of files uses a delimiter to define each field. The most common format is CSV but you can use your own based on a regular expression. The class TextFileDataset has three constants with pre-defined formats:

- TextFileDataset::CSVFILE - A generic file definition. It accepts `|`, `,` and `;` as delimiter.
- TextFileDataset::CSVFILE\_COMMA - The CSV file. It accepts only `,` as delimiter.
- TextFileDataset::CSVFILE\_SEMICOLON - A CSV variation. It accepts only `;` as delimiter.

example1.csv

```
Joao;Magalhaes
John;Doe
Jane;Smith
```

example1.php

```
