{"id":36398482,"url":"https://github.com/hhpack/file","last_synced_at":"2026-01-11T16:01:35.384Z","repository":{"id":29039951,"uuid":"32567484","full_name":"hhpack/file","owner":"hhpack","description":"File utility library for Hack","archived":false,"fork":false,"pushed_at":"2017-10-03T00:51:58.000Z","size":80,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-18T09:40:42.167Z","etag":null,"topics":["csv","field","hacklang","hhvm"],"latest_commit_sha":null,"homepage":"","language":"Hack","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/hhpack.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}},"created_at":"2015-03-20T06:43:21.000Z","updated_at":"2018-10-28T18:19:52.000Z","dependencies_parsed_at":"2022-08-21T11:50:50.119Z","dependency_job_id":null,"html_url":"https://github.com/hhpack/file","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/hhpack/file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhpack%2Ffile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhpack%2Ffile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhpack%2Ffile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhpack%2Ffile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hhpack","download_url":"https://codeload.github.com/hhpack/file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhpack%2Ffile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28312078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","field","hacklang","hhvm"],"created_at":"2026-01-11T16:00:37.881Z","updated_at":"2026-01-11T16:01:35.362Z","avatar_url":"https://github.com/hhpack.png","language":"Hack","funding_links":[],"categories":[],"sub_categories":[],"readme":"file\n======================================================\n\n[![Latest Stable Version](https://poser.pugx.org/hhpack/file/v/stable)](https://packagist.org/packages/hhpack/file)\n[![Build Status](https://travis-ci.org/hhpack/file.svg?branch=master)](https://travis-ci.org/hhpack/file)\n[![Dependency Status](https://www.versioneye.com/user/projects/56239db636d0ab0016000be8/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56239db636d0ab0016000be8)\n[![License](https://poser.pugx.org/hhpack/file/license)](https://packagist.org/packages/hhpack/file)\n\nThis package is a library for performing a simple to file operations hacklang.  \nWill provide a lightweight and simple api to the user.\n\n\nBasic usage\n------------------------------------------------------\n\nRead processing of files can be realized by a simple code as follows.\n\n### Reading one line at a time.\n\n```hack\nuse HHPack\\File\\FileLineStream;\n\n$lineStream = FileLineStream::fromString('/path/to/text.log');\n\nforeach ($lineStream as $line) {\n\techo $line-\u003elength(), \"\\n\"; //output length\n\techo $line-\u003evalue(), \"\\n\"; //output content\n};\n```\n\nRead the CSV file\n------------------------------------------------------\n\n```hack\nuse HHPack\\File\\FileLineStream;\nuse HHPack\\File\\SeparatedRecordStream;\nuse HHPack\\File\\ColumnSpecification;\n\n$spec = new ColumnSpecification(',', '\"');\n$spec-\u003eaddColumn(0, 'name');\n$spec-\u003eaddColumn(1, 'description');\n\n$lineStream = FileLineStream::fromString(__DIR__ . '/example.csv');\n$csvStream = new SeparatedRecordStream($lineStream, $spec);\n\nforeach ($csvStream as $record) {\n    echo $record-\u003eget('name'), \"\\n\";\n    echo $record-\u003eget('description'), \"\\n\";\n}\n```\n\nCustomizing the reading of the record\n------------------------------------------------------\n\nWill create a parser that implements the **ParseSpecification**.  \nThen use the **ParsedFileReader**, and then apply the parser.\n\n```hack\nuse HHPack\\File\\FileLineStream;\nuse HHPack\\File\\ParsedChunkStream;\nuse HHPack\\File\\ParseSpecification;\n\nfinal class CustomRecordSpecification implements ParseSpecification\u003carray\u003cstring\u003e\u003e\n{\n    public function parse(Chunk $line) : array\u003cstring\u003e\n    {\n        return $line-\u003esplit(',');\n    }\n}\n\n$spec = new CustomRecordSpecification();\n$lineStream = FileLineStream::fromString(__DIR__ . '/example.csv');\n$csvStream = new ParsedChunkStream($lineStream, $spec);\n\nforeach ($csvStream as $values) {\n    echo $values[0], \"\\n\";\n    echo $values[1], \"\\n\";\n}\n```\n\nRun the test\n------------------------------------------------\n\nYou can run the test with the following command.\n\n\tcomposer install\n\tcomposer test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhpack%2Ffile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhhpack%2Ffile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhpack%2Ffile/lists"}