PHPackages                             datatable/core - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. datatable/core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

datatable/core
==============

DataTable core and command-line tools

v1.1.0(8y ago)37.1k↓50%3MITPHP

Since Feb 17Pushed 8y ago2 watchersCompare

[ Source](https://github.com/DataTable/Core)[ Packagist](https://packagist.org/packages/datatable/core)[ Docs](http://www.github.com/datatable/core)[ RSS](/packages/datatable-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

The DataTable Library
=====================

[](#the-datatable-library)

Represents in-memory table data such as:

- Database tables
- Database result sets
- CSV files
- Excel files
- Data grids
- ... etc

Why use the DataTable library?
------------------------------

[](#why-use-the-datatable-library)

- Do you need to import end-user data from different formats into your system?
- Do you need to export data from your system into different formats?
- Did you ever import csv data into a database, then import from excel, yaml, xml, etc?
- Did you ever export data from a database into csv, then export to excel, yaml, xml, pdf, etc?

This is where a "DataTable" comes in. It sits *in between* your importers, exporters and your application data.

It allows you to write really awesome:

- Importers, based on DataTables
- Exporters, based on DataTables

If you write your importer based on a DataTable (instead of .csv, .xls, .yaml, etc directly), then you can write your importer once, and support *all* import formats that DataTable supports.

If you write your exporter based on a DataTable (instead of .csv, .xls, .yaml, etc directly), then you can write your exporter once, and support *all* export formats that DataTable supports.

How to load data into a Table from code:
----------------------------------------

[](#how-to-load-data-into-a-table-from-code)

```
use DataTable\Core\Table;
use DataTable\Core\Writer\Csv as CsvWriter;

$table = new Table();
$table->setName("My data"); // Give it a user-friendly name

$namecolumn = $table->getColumnByName("name");
$emailcolumn = $table->getColumnByName("email");

// get the first row (index 0)
$row = $table->getRowByIndex(0);

// get a cell by columnname:
$cell = $row->getCellByColumnName("name");
// assign value to the cell
$cell->setValue("Joe Johnson");

// do the same for the second cell (email)
$cell = $row->getCellByColumnName("email");
$cell->setValue("joe@johnson.web");

// do the same for a second row (index 1)
$row = $table->getRowByIndex(1);

$cell = $row->getCellByColumnName("name");
$cell->setValue("John Jackson");

$cell = $row->getCellByColumnName("email");
$cell->setValue("john@jackson.web");

// use a writer to export the datatable to a .csv file
$writer = new CsvWriter();
$output = $writer->write($table);
echo $output;
```

How to read data from code:
---------------------------

[](#how-to-read-data-from-code)

```
use DataTable\Core\Table;
use DataTable\Core\Reader\Csv as CsvReader;

// Create the DataTable\Core\Table object
$table = new Table();
$table->setName("My user data"); // Give it a user-friendly name
$reader->loadFile($table, "users.csv");

// Loop through all the rows in $table

foreach($table->getRows() as $row) {

  // Read field contents from the row by columnname
  $name = $row->getValueByColumnName("name");
  $email = $row->getValueByColumnName("email");

  // use the data, for example:
  // ensure database record for user with name+email
}
```

How to use the readers and writers for importing/exporting data
---------------------------------------------------------------

[](#how-to-use-the-readers-and-writers-for-importingexporting-data)

```
use DataTable\Core\Table;
use DataTable\Core\Reader\Csv as CsvReader;
use DataTable\Core\Writer\AsciiTable as AsciiTableWriter;

// Create the DataTable\Core\Table object
$table = new Table();
$table->setName(basename($inputfile)); // Give it a user-friendly name

// Instantiate a Reader, in this case a .csv file reader
$reader = new CsvReader();
$reader->setSeperator(',');
$reader->loadFile($table, $inputfile);

// The $table now contains data from the .csv file

// Instantiate a Writer, in this case an Ascii table writer
$writer = new AsciiTableWriter();
$output = $writer->write($table);
echo $output;
```

As you can see, the `DataTable\Core\Table` object is used to load, and then export data.

If you need to export data from your system into different formats, then all you need to do is

1. Load the data from your system into a DataTable
2. Use one of the many Writers to export the data into different formats

If you need to import data into your system from diffent formats, then all you need to do is:

1. Use one of the many Readers to import the data from any supported format into a DataTable
2. Write an importer for data from a DataTable into your system

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3012d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1db66b320db18b8036ea68211b7d8a39e7c6da97e6fd29f59a50380ebb69d0bb?d=identicon)[joostfaassen](/maintainers/joostfaassen)

---

Top Contributors

[![joostfaassen](https://avatars.githubusercontent.com/u/411113?v=4)](https://github.com/joostfaassen "joostfaassen (18 commits)")[![congpeijun](https://avatars.githubusercontent.com/u/881552?v=4)](https://github.com/congpeijun "congpeijun (1 commits)")

---

Tags

phpdataexportcoreimportdatatable

### Embed Badge

![Health badge](/badges/datatable-core/health.svg)

```
[![Health](https://phpackages.com/badges/datatable-core/health.svg)](https://phpackages.com/packages/datatable-core)
```

###  Alternatives

[hi-folks/data-block

Data class for managing nested arrays and JSON data.

1472.2k](/packages/hi-folks-data-block)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
