{"id":21206238,"url":"https://github.com/rtmigo/linecompress_py","last_synced_at":"2026-05-19T08:02:00.768Z","repository":{"id":138532990,"uuid":"449824411","full_name":"rtmigo/linecompress_py","owner":"rtmigo","description":"Stores text strings in a set of .txt.gz files. Minimalist solution for storing logs","archived":false,"fork":false,"pushed_at":"2022-02-13T20:13:24.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"staging","last_synced_at":"2026-01-02T23:14:46.525Z","etag":null,"topics":["logs","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/rtmigo.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":"2022-01-19T19:17:19.000Z","updated_at":"2022-07-18T19:49:35.000Z","dependencies_parsed_at":"2023-07-06T20:33:51.751Z","dependency_job_id":null,"html_url":"https://github.com/rtmigo/linecompress_py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rtmigo/linecompress_py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flinecompress_py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flinecompress_py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flinecompress_py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flinecompress_py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtmigo","download_url":"https://codeload.github.com/rtmigo/linecompress_py/tar.gz/refs/heads/staging","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Flinecompress_py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33207480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:54:09.561Z","status":"ssl_error","status_checked_at":"2026-05-19T07:54:08.508Z","response_time":58,"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":["logs","python"],"created_at":"2024-11-20T20:54:57.176Z","updated_at":"2026-05-19T08:02:00.752Z","avatar_url":"https://github.com/rtmigo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Generic badge](https://img.shields.io/badge/CI_Python-3.7_.._3.10-blue.svg)\n![Generic badge](https://img.shields.io/badge/CI_OS-Linux_|_Windows-blue.svg)\n\n# [linecompress_py](https://github.com/rtmigo/linecompress_py#readme)\n\nLibrary for storing text lines in compressed files.\n\nIt uses **.gz** compression format, so the data can be decompressed by any\ncompression utility with .gz support.\n\n# Install\n\n```\npip3 install git+https://github.com/rtmigo/linecompress_py#egg=linecompress\n```\n\n# Use\n\n`LinesDir` saves data to multiple files, making sure the files don't get too\nbig.\n\nThe files are filled sequentially: first we write only to `000.txt.gz`, then \nonly to `001.txt.gz`, and so on.\n\n\n```python3\nfrom pathlib import Path\nfrom linecompress import LinesDir\n\nlines_dir = LinesDir(Path('/parent/dir'),\n                     max_file_size=1000000)\nlines_dir.append('Line one')\nlines_dir.append('Line two')\n\n# reading from oldest to newest\nfor line in lines_dir:\n    print(line)\n\n# reading from newest to oldest\nfor line in reversed(lines_dir):\n    print(line)\n```\n\n# Directory structure\n\n```\n000/000/000.txt.gz \n000/000/001.txt.gz \n000/000/002.txt.gz \n...\n000/000/999.txt.gz \n000/001/000.txt.gz\n...\n000/001/233.txt.gz \n000/001/234.txt \n```\n\nThe last file usually contains raw text, not yet compressed.\n\n# Limitations\n\nThe default maximum file size is 1 million bytes (decimal megabyte).\n\nThis is the size of text data *before* compression.\n\nThe directory will hold up to a billion of these files. Thus, the maximum total\nstorage size is one decimal petabyte.\n\nBy changing the value of the `subdirs` argument, we change the maximum number of\nfiles: an increase in `subdirs` by one means an increase in the number of \nfiles by a thousand times.\n\nWith the default file size 1MB we get the following limits:\n\n\n| subdirs     | file path            | max sum size |\n|-------------|----------------------|--------------|\n| `subdirs=0` | `000.gz`             | gigabyte     |\n| `subdirs=1` | `000/000.gz`         | terabyte     |\n| `subdirs=2` | `000/000/000.gz`     | petabyte     |\n| `subdirs=3` | `000/000/000/000.gz` | exabyte      |\n\nThese are the data sizes before compression. The actual size of the files on \nthe disk will most likely be smaller.\n\nAdjusting the limits:\n\n```python3\nfrom pathlib import Path\nfrom linecompress import LinesDir\n\ngb = LinesDir(Path('/max/gigabyte'),\n              subdirs=1)\n\n# subdirs=2 is the default value\npb = LinesDir(Path('/max/petabyte'))\n\neb = LinesDir(Path('/max/exabyte'),\n              subdirs=3)\n```\n\nThe file size can also be adjusted.\n\n```python3\nfrom pathlib import Path\nfrom linecompress import LinesDir\n\n# the default buffer size is 1 MB\npb = LinesDir(Path('/max/petabyte'))\n\n# set file size to 5 MB\npb5 = LinesDir(Path('/max/5_petabytes'),\n               buffer_size=5000000)\n```\n\n* With larger files, we get better compression and less load on the file system.\n* With smaller files, we're much more efficient at iterating through lines in \n  reverse order.\n\n# See also\n\n* [linecompress_kt](https://github.com/rtmigo/linecompress_kt) – Kotlin/JVM \n  library","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Flinecompress_py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtmigo%2Flinecompress_py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Flinecompress_py/lists"}