{"id":18141556,"url":"https://github.com/skjolber/unzip-csv","last_synced_at":"2025-04-22T13:17:47.725Z","repository":{"id":42470649,"uuid":"141759247","full_name":"skjolber/unzip-csv","owner":"skjolber","description":"High-performance (i.e. multi-threaded) unpacking and processing of CSV files directly from ZIP archives.","archived":false,"fork":false,"pushed_at":"2025-03-21T07:07:27.000Z","size":48968,"stargazers_count":1,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T08:23:09.109Z","etag":null,"topics":["csv","http","parallel","performance","unzip"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skjolber.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-07-20T21:24:55.000Z","updated_at":"2024-10-01T19:49:46.000Z","dependencies_parsed_at":"2025-03-21T08:32:49.270Z","dependency_job_id":null,"html_url":"https://github.com/skjolber/unzip-csv","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skjolber%2Funzip-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skjolber%2Funzip-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skjolber%2Funzip-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skjolber%2Funzip-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skjolber","download_url":"https://codeload.github.com/skjolber/unzip-csv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246201153,"owners_count":20739707,"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","http","parallel","performance","unzip"],"created_at":"2024-11-01T17:07:36.998Z","updated_at":"2025-03-31T02:31:48.148Z","avatar_url":"https://github.com/skjolber.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unzip-csv\nHigh-performance (i.e. multi-threaded) unpacking and processing of CSV files directly from ZIP archives.\n\nProjects using this library will benefit from:\n * parallel unzip and processing of files (in streaming fashion)\n * per-file adapters (based on file-name)\n * hooks for pre- and post-processing \n * cutting large files into segments for further parallel processing \n * unzip specific files over-the-wire (with HTTP Range)\n   * parallel, on-demand download\n   * extract specific files without downloading the full archive\n\nCutting files into segments (based on newline) assumes that \n\n * line order is not important,\n * newlines can be decoded from reading the file backwards - this is true for popular character encodings like [UTF-8], ASCII and ISO-8859-1. \n * CSV entries are without linebreaks; not even linebreak wrapped in quotes.\n \nIf cutting into segments is not possible then using a [parallel reader](src/main/java/com/github/skjolber/unzip/csv/ParallelReader.java) is also an option; effectively decoding to characters and parsing in parallel.\n\nBugs, feature suggestions and help requests can be filed with the [issue-tracker].\n\n## Obtain\nThe project is implemented in Java and built using [Maven]. The project is available on the central Maven repository.\n\nExample dependency config:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.skjolber.unzip-csv\u003c/groupId\u003e\n    \u003cartifactId\u003eunzip-csv\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.10\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Usage\nThe top level `FileEntryHandler` is passed to the `ZipFileEngine`. \n\n\n```java\nFileEntryHandler handler = ...; // your code here\n\nZipFileEngine engine = new ZipFileEngine(handler);\nboolean success = engine.handle(new FileZipFileFactory(file));\n```\nwhere the default thread count is one per core.\n\n## Pre- and post-processing\nWire `FileEntryHandler` methods \n\n```java\nvoid beginFileCollection(String name);\nvoid beginFileEntry(String name);\nvoid endFileEntry(String name, ThreadPoolExecutor executor);\nvoid endFileCollection(String name, ThreadPoolExecutor executor);\nFileEntryStreamHandler getFileEntryStreamHandler(String name, long size, ThreadPoolExecutor executor);\n```\n\nfor pre- or post-processing. Call the super method wherever it exists. Notice the `ThreadPoolExecutor` which allows for queuing more work.\n\n\n## Sesseltjonna CSV parser\nImplement an instance of `CsvLineHandlerFactory` to return specific handlers for each file in the ZIP archive.\n\nThen use the provided adapters to implement a `FileEntryHandler` like in [this example](src/test/java/com/github/skjolber/unzip/TestSesselTjonnaCsvFileEntryHandler.java). \n\n## Univocity CSV parser\nImplement an instance of `CsvLineHandlerFactory` to return specific handlers for each file in the ZIP archive. Then create a `DefaultUnivocityCsvFileEntryHandler` and pass it to the ZipFileEngine`.\n\n# Details\nThe main performance-enhanching functions are\n * parallelization; unzip and process files and/or parts of files\n * unzip remote files while downloading only the necessary parts\n\nZIP files carry a `central directory` in the end of the file, detailing the name and location of the files within. parallel unzipping works better if the archive is compressed using the DEFLATE compression algorithm - see Apache [commons-compress](https://commons.apache.org/proper/commons-compress/zip.html) for additional details.\n\n\n## Benchmarks\nFor simple [GTFS feeds] with an archive size of approximately 70 MB, which both unzips and processes file segments in parallel (parsing the CSV file lines), the performance on my laptop (4 cores + hyperthreading) is appoximately 1.5x-2x that of a linear unzip. \n\nDepending on your scenario, the the effect of processing file segments in parallel might be a considerable speedup, improving on the above result.\n\n# Contact\nIf you have any questions or comments, please email me at thomas.skjolberg@gmail.com.\n\nFeel free to connect with me on [LinkedIn], see also my [Github page].\n## License\n[Apache 2.0]\n\n## Links\nOther high-performance CSV parsers:\n\n * [SimpleFlatMapper](https://simpleflatmapper.org/)\n * [Univocity-parsers](https://github.com/uniVocity/univocity-parsers)\n\n# History\n - 1.0.10: Maintenance release \n - 1.0.9: Update CSV parsers\n - 1.0.8: Automatic module name for JDK9+.\n - 1.0.7: Add optional Parallel reader (from SimpleFlatMapper project).\n\n[GTFS feeds]:\t\t\thttps://www.entur.org/dev/rutedata/\n[Apache 2.0]: \t\t\thttp://www.apache.org/licenses/LICENSE-2.0.html\n[issue-tracker]:\t\thttps://github.com/skjolber/unzip-csv/issues\n[Maven]:\t\t\t\thttp://maven.apache.org/\n[LinkedIn]:\t\t\t\thttp://lnkd.in/r7PWDz\n[Github page]:\t\t\thttps://skjolber.github.io\n[UTF-8]:\t\t\t\thttps://stackoverflow.com/questions/22257486/iterate-backwards-through-a-utf8-multibyte-string\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskjolber%2Funzip-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskjolber%2Funzip-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskjolber%2Funzip-csv/lists"}