{"id":24780410,"url":"https://github.com/webgriffe/amp-csv","last_synced_at":"2025-10-12T04:31:14.452Z","repository":{"id":62547758,"uuid":"124789650","full_name":"webgriffe/amp-csv","owner":"webgriffe","description":"CSV library to use with Amp PHP framework.","archived":false,"fork":false,"pushed_at":"2025-07-03T13:21:35.000Z","size":65,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-01T03:14:35.020Z","etag":null,"topics":["csv"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webgriffe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-11T19:14:29.000Z","updated_at":"2025-07-03T13:20:55.000Z","dependencies_parsed_at":"2025-01-29T10:30:34.284Z","dependency_job_id":"71d703c2-c93a-439a-910c-ec3e7f3c4be0","html_url":"https://github.com/webgriffe/amp-csv","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/webgriffe/amp-csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webgriffe%2Famp-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webgriffe%2Famp-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webgriffe%2Famp-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webgriffe%2Famp-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webgriffe","download_url":"https://codeload.github.com/webgriffe/amp-csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webgriffe%2Famp-csv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002401,"owners_count":26083375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv"],"created_at":"2025-01-29T10:30:24.431Z","updated_at":"2025-10-12T04:31:14.163Z","avatar_url":"https://github.com/webgriffe.png","language":"PHP","funding_links":[],"categories":["CSV"],"sub_categories":[],"readme":"# AMP Comma Separated Values Library\n\n[![Build Status](https://travis-ci.org/webgriffe/amp-csv.svg?branch=master)](https://travis-ci.org/webgriffe/amp-csv)\n\nCSV library to use with [Amp](https://amphp.org/) PHP framework.\nCurrently it implements only an iterator which allows to parse CSV rows one at a time.\n\n## Installation\n\nRequire this package using [Composer](https://getcomposer.org/):\n\n    composer require webgriffe/amp-csv\n  \n## Iterator Usage\n\nThis library implements an Amp's [Iterator](https://amphp.org/amp/iterators/) which allows to iterate over CSV rows one at a time.\nPotentially it can parse very large CSV files because only small chunks are kept in memory.\nSee the following example, given this CSV file (`path/to/file.csv`):\n\n```csv\nName,Description,Price,Stock\nRaspberryPi,\"Raspberry PI Modell B, 512 MB\",37.05,12\nSanDisk Ultra SDHC,SanDisk Ultra SDHC 8 GB 30 MB/s Classe 10,6.92,54\n```\n\nWe can have:\n\n```php\n\u003c?php\n\nuse Webgriffe\\AmpCsv\\Iterator;\nuse Webgriffe\\AmpCsv\\Parser;\nuse Amp\\File;\n\nrequire_once 'vendor/autoload.php';\n\n\\Amp\\Loop::run(function () {\n    $iterator = new Iterator(new Parser(yield File\\open('path/to/file.csv', 'rb')));\n    while (yield $iterator-\u003eadvance()) {\n        $rows[] = $iterator-\u003egetCurrent();\n    }\n    var_dump($rows);\n});\n```\n\nAnd the output will be:\n\n```text\narray(\n    array(\n        'Name' =\u003e 'RaspberryPi',\n        'Description' =\u003e 'Raspberry PI Modell B, 512 MB',\n        'Price' =\u003e 37.05,\n        'Stock' =\u003e 12,\n    ),\n    array(\n        'Name' =\u003e 'SanDisk Ultra SDHC',\n        'Description' =\u003e 'SanDisk Ultra SDHC 8 GB 30 MB/s Classe 10',\n        'Price' =\u003e 6.92,\n        'Stock' =\u003e 54,\n    ),\n),\n```\n\nBy default the iterator treats the first line as header and will use the column names to index row values.\nIf a row has a different column number than header an exception will be thrown.\nIf your CSV doesn't have an header as first line you can disable the header parsing by passing `false` as constructor's second argument:\n\n```php\n$iterator = new Iterator(new Parser(yield File\\open('path/to/file.csv', 'rb')), false);\n```\n\nContributing\n------------\n\nTo contribute simply fork this repository, do your changes and then propose a pull requests.\nYou should run coding standards check and tests as well:\n\n```bash\nvendor/bin/phpcs --standard=PSR2 src\nvendor/bin/phpunit\n```\n\nLicense\n-------\nThis library is under the MIT license. See the complete license in the LICENSE file.\n\nCredits\n-------\nDeveloped by [Webgriffe®](http://www.webgriffe.com/).\nThanks also to [Niklas Keller](https://github.com/kelunik) for his help about converting ReactPHP stream events to an Amp's Iterator (see [https://github.com/reactphp/promise-stream/issues/14](https://github.com/reactphp/promise-stream/issues/14)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebgriffe%2Famp-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebgriffe%2Famp-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebgriffe%2Famp-csv/lists"}