{"id":16355403,"url":"https://github.com/alexskrypnyk/csvtable","last_synced_at":"2025-03-23T01:31:19.833Z","repository":{"id":167433069,"uuid":"643049406","full_name":"AlexSkrypnyk/CsvTable","owner":"AlexSkrypnyk","description":"PHP class to work with CSV as a table and export it as Markdown.","archived":false,"fork":false,"pushed_at":"2025-02-07T08:54:31.000Z","size":54,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T16:14:18.902Z","etag":null,"topics":["converter","csv","formatter","markdown","table"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexSkrypnyk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"AlexSkrypnyk"}},"created_at":"2023-05-20T00:52:33.000Z","updated_at":"2025-01-09T22:05:41.000Z","dependencies_parsed_at":"2024-05-16T23:23:41.059Z","dependency_job_id":"517125b8-2378-4dcf-8e06-d73e1209dbbc","html_url":"https://github.com/AlexSkrypnyk/CsvTable","commit_stats":null,"previous_names":["alexskrypnyk/csvtable"],"tags_count":3,"template":false,"template_full_name":"AlexSkrypnyk/scaffold","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2FCsvTable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2FCsvTable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2FCsvTable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2FCsvTable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexSkrypnyk","download_url":"https://codeload.github.com/AlexSkrypnyk/CsvTable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245043931,"owners_count":20551852,"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":["converter","csv","formatter","markdown","table"],"created_at":"2024-10-11T01:40:47.414Z","updated_at":"2025-03-23T01:31:19.826Z","avatar_url":"https://github.com/AlexSkrypnyk.png","language":"PHP","funding_links":["https://patreon.com/AlexSkrypnyk"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"\" rel=\"noopener\"\u003e\n  \u003cimg width=200px height=200px src=\"https://placehold.jp/000000/ffffff/200x200.png?text=CsvTable\u0026css=%7B%22border-radius%22%3A%22%20100px%22%7D\" alt=\"Yourproject logo\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003ePHP class to parse and format CSV content\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![GitHub Issues](https://img.shields.io/github/issues/AlexSkrypnyk/CsvTable.svg)](https://github.com/AlexSkrypnyk/CsvTable/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/AlexSkrypnyk/CsvTable.svg)](https://github.com/AlexSkrypnyk/CsvTable/pulls)\n[![Test](https://github.com/AlexSkrypnyk/CsvTable/actions/workflows/test-php.yml/badge.svg)](https://github.com/AlexSkrypnyk/CsvTable/actions/workflows/test-php.yml)\n[![codecov](https://codecov.io/gh/AlexSkrypnyk/CsvTable/graph/badge.svg?token=7WEB1IXBYT)](https://codecov.io/gh/AlexSkrypnyk/CsvTable)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/AlexSkrypnyk/CsvTable)\n![LICENSE](https://img.shields.io/github/license/AlexSkrypnyk/CsvTable)\n![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)\n\n\u003c/div\u003e\n\n---\n\n## Features\n\n- Single-file class to manipulate CSV table.\n- Formatters for CSV, text table and Markdown table.\n- Support for a custom formatter.\n\n## Installation\n\n```bash\ncomposer require alexskrypnyk/csvtable\n```    \n\n## Usage\n\nGiven a CSV file with the following content:\n```csv\ncol11,col12,col13\ncol21,col22,col23\ncol31,col32,col33      \n```\n\n### From string\n\n```php\n$csv = file_get_contents($csv_file);\n// Format using the default formatter.\nprint (new CsvTable($csv))-\u003eformat();\n```\nwill produce identical CSV content by default:\n```csv\ncol11,col12,col13\ncol21,col22,col23\ncol31,col32,col33      \n```\n\n### From file\n\n```php\nprint (CsvTable::fromFile($file))-\u003eformat();\n```\nwill produce identical CSV content by default:\n```csv\ncol11,col12,col13\ncol21,col22,col23\ncol31,col32,col33\n```\n\n### Using `text_table` formatter\n\n```php\nprint (CsvTable::fromFile($file))-\u003eformat('text_table');\n```\nwill produce table content:\n```csv\ncol11|col12|col13\n-----------------\ncol21|col22|col23\ncol31|col32|col33     \n```\n\n### Using `text_table` formatter without a header\n\n```php\nprint (CsvTable::fromFile($file))-\u003ewithoutHeader()-\u003eformat('text_table');\n```\nwill produce table content:\n```csv\ncol11|col12|col13\ncol21|col22|col23\ncol31|col32|col33     \n```\n\n### Using `markdown_table` formatter\n\n```php\nprint (CsvTable::fromFile($file))-\u003eformat('markdown_table');\n```\nwill produce Markdown table:\n```markdown\n| col11 | col12 | col13 |\n|-------|-------|-------|\n| col21 | col22 | col23 |\n| col31 | col32 | col33 |     \n```\n\n### Custom formatter as an anonymous callback\n\n```php\nprint (CsvTable::fromFile($file))-\u003eformat(function ($header, $rows, $options) {\n  $output = '';\n\n  if (count($header) \u003e 0) {\n    $output = implode('|', $header);\n    $output .= \"\\n\" . str_repeat('=', strlen($output)) . \"\\n\";\n  }\n\n  return $output . implode(\"\\n\", array_map(static function ($row): string {\n    return implode('|', $row);\n  }, $rows));\n});\n```\nwill produce CSV content:\n```csv\ncol11|col12|col13\n=================\ncol21|col22|col23\ncol31|col32|col33     \n```\n\n### Custom formatter as a class with default `format` method\n\n```php\nprint (CsvTable::fromFile($file))-\u003ewithoutHeader()-\u003eformat(CustomFormatter::class);\n```\n\n### Custom formatter as a class with a custom method and options\n\n```php\n$formatter_options = ['option1' =\u003e 'value1', 'option2' =\u003e 'value2'];\nprint (CsvTable::fromFile($file))-\u003ewithoutHeader()-\u003eformat([CustomFormatter::class, 'customFormat'], $formatter_options);\n```\n\n## Maintenance\n\n```bash\ncomposer install\ncomposer lint\ncomposer test\n```\n---\n_This repository was created using the [Scaffold](https://getscaffold.dev/) project template_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexskrypnyk%2Fcsvtable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexskrypnyk%2Fcsvtable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexskrypnyk%2Fcsvtable/lists"}