PHPackages                             jcoded/atoc-data-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jcoded/atoc-data-parser

ActivePackage[Parsing &amp; Serialization](/categories/parsing)

jcoded/atoc-data-parser
=======================

A parser for the ATOC data files.

2.0(9y ago)1101MITPHPPHP &gt;=5.4.0

Since Jul 16Pushed 9y ago2 watchersCompare

[ Source](https://github.com/JCoded/atoc-data-parser)[ Packagist](https://packagist.org/packages/jcoded/atoc-data-parser)[ RSS](/packages/jcoded-atoc-data-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/0e2f9e08473f722759b50cd4317487776de86ac9b270d5158be4ef09d87d5836/68747470733a2f2f7472617669732d63692e6f72672f4a436f6465642f61746f632d646174612d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JCoded/atoc-data-parser)

ATOC Data Parser
================

[](#atoc-data-parser)

This package allows you to parse the timetable and fares files contained within the ATOC data download available at

It does not parse files that are identified as not maintained in the ATOC specification document.

Installation
------------

[](#installation)

You can install this package through Composer. Add the following line to your composer.json `require` object:

```
"jcoded/atoc-data-parser": "2.*"

```

Record identity
---------------

[](#record-identity)

A field has been added to each record to help easily identify it, when using a Repository service for example. From the record identity it is possible to map the record to a table in your database. The record identity is constructed from the file extension followed by the `RECORD_TYPE` if present.

Field naming
------------

[](#field-naming)

To create information that is easier to consume some field names vary from the specification to keep them uniform, the table below details the field name to expect from this parser and which field that relates to in the specification.

Parser fieldTimetable dataFares dataDescriptionRECORD\_TYPERecord identityRECORD\_TYPEOptionally included in the data specificationRECORD\_IDENTITYThe identity given by this parserUsage
-----

[](#usage)

To get a parser object use the Factory based on the filename being parsed:

```
$filename = "RJFAF570.NDF";
$factory = new \JCoded\AtocDataParser\Factory();
$parser = $factory->getParser($filename);
```

Then use the parser object to loop through each of the lines of the file.

```
while (($line = fgets($stream)) !== false) {
    //Skip the comments
    if (strpos($line, '/!!') !== false) {
        continue;
    }

    //Get the data
    try {
        $data = $parser->parseLine($line);

        //Do something with the data

    } catch (\JCoded\AtocDataParser\IncompatibleLineException $ex) {
        //Handle exception
    }
}
```

The parser will return an associative array with a key equal to the field name in the specification document, see the example below. The specification documents can be found on the ATOC site.

```
[
    'TICKET_CODE' => '0AW',
    'RESTRICTION_CODE' => 'SV',
    'RESTRICTION_FLAG' => '0',
    'TOC_ID' => 'SN',
    'END_DATE' => '31122999',
    'START_DATE' => '30042013',
    'CHECK_TYPE' => '2',
    'AP_DATA' => '00000001',
    'BOOKING_TIME' => '1800',
    'RECORD_IDENTITY' => 'TAP'
]
```

### Dependency injection

[](#dependency-injection)

There are a some interfaces to use when injecting dependencies into your classes.

The interface for the Factory:

```
\JCoded\AtocDataParser\ParserFactoryInterface
```

The interface for the returned parser:

```
\JCoded\AtocDataParser\File\ParserInterface
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~168 days

Total

2

Last Release

3425d ago

Major Versions

1.0 → 2.02017-01-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c7d2e50d30763189f18b88ba3eb7094af8687a27c7df3fc8a43bd686a9e108c?d=identicon)[madebyjames](/maintainers/madebyjames)

---

Top Contributors

[![madebyjames](https://avatars.githubusercontent.com/u/8142061?v=4)](https://github.com/madebyjames "madebyjames (11 commits)")

---

Tags

uk railATOCAssociation of Train Operating Companiesuk traintrain data parser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jcoded-atoc-data-parser/health.svg)

```
[![Health](https://phpackages.com/badges/jcoded-atoc-data-parser/health.svg)](https://phpackages.com/packages/jcoded-atoc-data-parser)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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