Skip to content

Commit 296b1e5

Browse files
committed
First commit
1 parent d42c36b commit 296b1e5

File tree

11 files changed

+4198
-14
lines changed

11 files changed

+4198
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ composer.phar
44
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
55
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
66
# composer.lock
7+
.idea
8+
.vscode

README.md

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
# PHP DSV Reader & Writer
22

3-
[Why you should use and prefer DSV format instead of CSV?](https://matthodges.com/posts/2024-08-12-csv-bad-dsv-good/)
3+
Inspired by: [Why you should use and prefer DSV format instead of CSV](https://matthodges.com/posts/2024-08-12-csv-bad-dsv-good/)
44

5-
[![CodeCov](https://codecov.io/gh/terremoth/vendor/graph/badge.svg?token=TOKEN)](https://app.codecov.io/gh/terremoth/vendor)
6-
[![Psalm type coverage](https://shepherd.dev/github/terremoth/vendor/coverage.svg)](https://shepherd.dev/github/terremoth/vendor)
7-
[![Psalm level](https://shepherd.dev/github/terremoth/vendor/level.svg)](https://shepherd.dev/github/terremoth/vendor)
8-
[![Test Run Status](https://github.com/terremoth/vendor/actions/workflows/workflow.yml/badge.svg?branch=main)](https://github.com/terremoth/vendor/actions/workflows/workflow.yml)
9-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/CODE)](https://app.codacy.com/gh/terremoth/vendor/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
10-
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/CODE/maintainability)](https://codeclimate.com/github/terremoth/vendor/maintainability)
11-
[![License](https://img.shields.io/github/license/terremoth/vendor.svg?logo=gnu&color=41bb13)](https://github.com/terremoth/vendor/blob/main/LICENSE)
5+
[![CodeCov](https://codecov.io/gh/terremoth/php-dsv/graph/badge.svg?token=TOKEN)](https://app.codecov.io/gh/terremoth/php-dsv)
6+
[![Psalm type coverage](https://shepherd.dev/github/terremoth/php-dsv/coverage.svg)](https://shepherd.dev/github/terremoth/php-dsv)
7+
[![Psalm level](https://shepherd.dev/github/terremoth/php-dsv/level.svg)](https://shepherd.dev/github/terremoth/php-dsv)
8+
[![Test Run Status](https://github.com/terremoth/php-dsv/actions/workflows/workflow.yml/badge.svg?branch=main)](https://github.com/terremoth/php-dsv/actions/workflows/workflow.yml)
9+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/CODE)](https://app.codacy.com/gh/terremoth/php-dsv/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
10+
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/CODE/maintainability)](https://codeclimate.com/github/terremoth/php-dsv/maintainability)
11+
[![License](https://img.shields.io/github/license/terremoth/php-dsv.svg?logo=gnu&color=41bb13)](https://github.com/terremoth/php-dsv/blob/main/LICENSE)
1212

13-
See [demos/demo.php](demos/demo.php) for examples.
13+
See [demos/demo.php](demos/demo.php) for examples.
1414

1515
## Installation
16+
17+
```shell
18+
composer require terremoth/php-dsv --no-dev
19+
```
20+
21+
## Usage:
22+
23+
```php
24+
require_once 'vendor/autoload.php';
25+
26+
use DSV\DSVWriter;
27+
use DSV\DSVReader;
28+
29+
$data = [
30+
['Name', 'Comment'],
31+
['Alice', 'She said, "Hello" and waved.'],
32+
['Bob', 'This is a multi-line comment\r\nspanning two lines.'],
33+
['Charlie', 'More fun with\ntwo lines.'],
34+
['Diana', 'How about some UTF-8: café, naïve, résumé. 📝'],
35+
['Edward', 'アップル'],
36+
];
37+
38+
$writer = new DSVWriter('demos/data.dsv');
39+
$writer->write($data); // will write the $data to file in DSV format
40+
41+
$reader = new DSVReader('demos/data.dsv');
42+
print_r($reader->read()); // will read the demos/data.dsv file and put it in array format
43+
```

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
2-
"name": "terremoth/",
2+
"name": "terremoth/php-dsv",
33
"description": "",
44
"type": "library",
55
"require": {
66
"php": "^8.1"
77
},
88
"keywords": [
9-
"project-template",
9+
"dsv",
10+
"data-parsing",
11+
"data-extraction"
1012
],
1113
"require-dev": {
1214
"phpunit/phpunit": "^10.0",
@@ -15,15 +17,15 @@
1517
"squizlabs/php_codesniffer": "*",
1618
"phpmd/phpmd": "@stable"
1719
},
18-
"license": "GPL-3.0-or-later",
20+
"license": "MIT",
1921
"autoload": {
2022
"psr-4": {
21-
"\\": "src/"
23+
"DSV\\": "src/DSV"
2224
}
2325
},
2426
"autoload-dev": {
2527
"psr-4": {
26-
"\\Tests\\": "tests/"
28+
"DSV\\Tests\\": "tests/DSV"
2729
}
2830
},
2931
"authors": [

0 commit comments

Comments
 (0)