agence-dnd-bundle / csv-converter
为 agence dnd 提供的 csv 转换器
dev-master
2022-04-24 13:23 UTC
Requires
- php: >=7.2
- phplucidframe/console-table: ^1.2
- symfony/framework-bundle: ^4.4
This package is not auto-updated.
Last update: 2024-09-23 23:31:13 UTC
README
本项目允许将 CSV 文件转换为表格。
安装
git clone https://github.com/manellelaamarti/csv-converter.git
cd csv-bundle
composer install
使用转换器
命令行
> php csv-parser.php test.csv
读取文件: csv-parser.php -> 执行读取和格式化代码 + CsvBundle 代码(数据格式化)。
读取文件: test.csv -> 测试文件。
sku;title;is_enabled;price;currency;description;created_at
628937273;Cornelia, the dark unicorn;1;14.87;€;Cornelia, \rThe Dark Unicorn.;2018-12-12 10:34:39
722821313;Be my bestie;0;18.80;€;Be <br/>my bestie, darling sweet.;2018-12-12 10:34:39
命令行结果
+-----------+----------------------------+---------+--------+-----------------------------------+----------------------+
| Sku | Title | Status | Price | Description | Created at |
+-----------+----------------------------+---------+--------+-----------------------------------+----------------------+
| 628937273 | cornelia--the-dark-unicorn | Enable | 14.87€ | Cornelia, \rThe Dark Unicorn. | 2018-12-12 10:34:39 |
| 722821313 | be-my-bestie | Disable | 18.80€ | Be <br/>my bestie, darling sweet. | 2018-12-12 10:34:39 |
+-----------+----------------------------+---------+--------+-----------------------------------+----------------------+
CsvBundle.php
重要方法
formatHeaders() - parseRows()
Méthodes me permettant de définir chaque entête de mon tableau ainsi que chaque colonne,
Dans celles-ci je m'occupe de leur formatage par rapport aux consignes données
(voir commentaires dans le code)