jcoded/atoc-data-parser
Composer 安装命令:
composer require jcoded/atoc-data-parser
包简介
A parser for the ATOC data files.
README 文档
README
ATOC Data Parser
This package allows you to parse the timetable and fares files contained within the ATOC data download available at http://data.atoc.org/data-download
It does not parse files that are identified as not maintained in the ATOC specification document.
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
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
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 field | Timetable data | Fares data | Description |
|---|---|---|---|
| RECORD_TYPE | Record identity | RECORD_TYPE | Optionally included in the data specification |
| RECORD_IDENTITY | The identity given by this parser |
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
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
jcoded/atoc-data-parser 适用场景与选型建议
jcoded/atoc-data-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ATOC」 「Association of Train Operating Companies」 「uk rail」 「uk train」 「train data parser」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jcoded/atoc-data-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jcoded/atoc-data-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jcoded/atoc-data-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.
Utilities for handling files inside domain entities: EmbeddedMetadata for embedding metadata inside Doctrine entities, AbstractFile for creating one-to-many relations with files, and NullFile to handle cases in domain entities where a file must be present but is missing in the storage backend.
Interface for file association. To be implemented in entities that support file association.
Handles the association between Doctrine entities and files using the rekalogika/file framework, including from file uploads.
Provides a simple way to generate an ABA file which is used by banks to allow for batch transactions.
rzd api
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-05