{"id":21056025,"url":"https://github.com/xp-framework/csv","last_synced_at":"2025-06-11T18:07:03.895Z","repository":{"id":459876,"uuid":"14297135","full_name":"xp-framework/csv","owner":"xp-framework","description":"CSV File handling for the XP Framework","archived":false,"fork":false,"pushed_at":"2024-03-24T11:46:12.000Z","size":3381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-30T13:09:11.908Z","etag":null,"topics":["csv","php","stream","xp-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-framework.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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":"2013-11-11T09:52:51.000Z","updated_at":"2021-10-21T19:28:07.000Z","dependencies_parsed_at":"2024-02-25T14:32:34.567Z","dependency_job_id":"059184dc-3bfa-4142-8e33-620421e372c5","html_url":"https://github.com/xp-framework/csv","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/xp-framework/csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcsv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcsv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcsv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcsv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-framework","download_url":"https://codeload.github.com/xp-framework/csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcsv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259312662,"owners_count":22838978,"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","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","php","stream","xp-framework"],"created_at":"2024-11-19T16:48:21.538Z","updated_at":"2025-06-11T18:07:03.852Z","avatar_url":"https://github.com/xp-framework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"CSV File handling for the XP Framework\n========================================================================\n\n[![Build status on GitHub](https://github.com/xp-framework/csv/workflows/Tests/badge.svg)](https://github.com/xp-framework/csv/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-framework/csv/version.png)](https://packagist.org/packages/xp-framework/csv)\n\nContains the XP Framework's CSV API\n\nReading\n-------\nCSV data can be read off any input stream, reader or channel:\n\n```php\nuse util\\cmd\\Console;\nuse text\\csv\\CsvListReader;\nuse io\\streams\\FileInputStream;\n\n$csv= new CsvListReader(new FileInputStream('in.csv'));\nConsole::writeLine($csv-\u003egetHeaders());\n\nwhile ($record= $csv-\u003eread()) {\n  Console::writeLine('- ', $record);\n}\n\n$csv-\u003eclose();\n```\n\nWriting\n-------\nCSV data can be written to any output stream, writer or channel:\n\n```php\nuse util\\cmd\\Console;\nuse text\\csv\\CsvListWriter;\nuse io\\streams\\FileOutputStream;\n\n$csv= new CsvListWriter(new FileOutputStream('out.csv'));\n\n$csv-\u003esetHeader(['name', 'city', 'zip']);\n$csv-\u003ewrite(['Timm', 'Karlsruhe', 76137]);\n$csv-\u003ewrite(['Alex', 'Karlsruhe', 76131]);\n\n$csv-\u003eclose();\n```\n\nCharacter set conversion\n------------------------\nCharacter set decoding is accomplished by passing a TextReader or TextWriter instance with a given character set:\n\n```php\nuse text\\csv\\{CsvListReader, CsvListWriter};\nuse io\\streams\\{FileInputStream, FileOutputStream, TextReader, TextWriter};\n\n// Read from in.csv, which is in cp1252\n$in= new CsvListReader(new TextReader(new FileInputStream('in.csv'), 'cp1252'));\n\n// Write to out.csv, converting everything to cp1252\n$out= new CsvListWriter(new TextWriter(new FileOutputStream('out.csv'), 'cp1252'));\n```\n\nFormat\n------\nCSV files usually use the semi-colon to separate values. Depending on the file we're parsing, this might be a different character. Both readers and writers accept an optional second parameter with which the format can be changed.\n\n```php\nuse text\\csv\\{CsvFormat, CsvListReader, CsvListWriter};\n\n$format= (new CsvFormat())-\u003ewithDelimiter(',');\n$format= CsvFormat::$COMMAS;    // Short-hand for the above\n\n$writer= new CsvListWriter(..., $format);\n$reader= new CsvListReader(..., $format);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fcsv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-framework%2Fcsv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fcsv/lists"}