{"id":17449727,"url":"https://github.com/bolner/lineartsvparser","last_synced_at":"2026-05-17T02:09:31.498Z","repository":{"id":148174605,"uuid":"233239253","full_name":"bolner/LinearTsvParser","owner":"bolner","description":"Linear TSV Parser for .NET Core (read, write)","archived":false,"fork":false,"pushed_at":"2020-01-18T20:39:24.000Z","size":49,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T03:59:35.316Z","etag":null,"topics":["async","dotnet-core","library","linear-tsv","parser","tsv"],"latest_commit_sha":null,"homepage":"","language":"C#","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/bolner.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":"2020-01-11T13:50:46.000Z","updated_at":"2023-11-04T20:37:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"64184580-50f1-467c-8638-8a4253a5acb4","html_url":"https://github.com/bolner/LinearTsvParser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bolner/LinearTsvParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolner%2FLinearTsvParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolner%2FLinearTsvParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolner%2FLinearTsvParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolner%2FLinearTsvParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bolner","download_url":"https://codeload.github.com/bolner/LinearTsvParser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolner%2FLinearTsvParser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33125184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"online","status_checked_at":"2026-05-17T02:00:05.366Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["async","dotnet-core","library","linear-tsv","parser","tsv"],"created_at":"2024-10-17T21:49:14.468Z","updated_at":"2026-05-17T02:09:31.472Z","avatar_url":"https://github.com/bolner.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Linear TSV Parser\n=================\n\nReading and writing `Linear TSV` files in a safe, lossless way. Both async and sync I/O operations are supported.\n\n# NuGet package\n\nAvailable at: https://www.nuget.org/packages/LinearTsvParser\n\nTo include it in a `.NET Core` project:\n\n```bash\n$ dotnet add package LinearTsvParser\n```\n\n# Examples\n\nReading a `.tsv.gz` file in async mode:\n\n```csharp\nusing System.IO;\nusing System.IO.Compression;\nusing System.Threading.Tasks;\nusing System.Collections.Generic;\nusing LinearTsvParser;\n\npublic class Example {\n    public async Task ReadTsv() {\n        using var input = File.OpenRead(\"/tmp/test.tsv.gz\");\n        using var gzip = new GZipStream(input, CompressionMode.Decompress);\n        using var tsvReader = new TsvReader(gzip);\n\n        while(!tsvReader.EndOfStream) {\n            List\u003cstring\u003e fields = await tsvReader.ReadLineAsync();\n        }\n    }\n}\n```\n\nWriting a `.tsv.gz` file in sync mode:\n\n```csharp\nusing System.IO;\nusing System.IO.Compression;\nusing System.Collections.Generic;\nusing LinearTsvParser;\n\npublic class Example {\n    public void WriteTsv(List\u003cstring[]\u003e data) {\n        using var outfile = File.Create(\"/tmp/test.tsv.gz\");\n        using var gzip = new GZipStream(outfile, CompressionMode.Compress);\n        using var tsvWriter = new TsvWriter(gzip);\n\n        tsvWriter.WriteLine(new List\u003cstring\u003e{ \"One\", \"Two\\tTwo\", \"Three\" });\n\n        foreach(string[] fields in data) {\n            tsvWriter.WriteLine(fields);\n        }\n    }\n}\n```\n\nThe writer accepts any `enumerable` of strings, let it be `string[]` or `List\u003cstring\u003e`.\n\nYou can output the TSV to the standard output by using `Console.Out` in the constructor:\n\n```csharp\nusing System;\nusing System.IO;\nusing LinearTsvParser;\n\npublic class Example {\n    public void WriteTsv() {\n        using var tsvWriter = new TsvWriter(Console.Out));\n\n        tsvWriter.WriteLine(new string[] {\"One\", \"Two\", \"Three\"});\n    }\n}\n```\n\nYou can ensure that the data hits the physical drive by calling `FlushAsync`.\n```csharp\npublic async Task WriteTsv(Stream output) {\n    using var tsvWriter = new TsvWriter(output);\n    \n    await tsvWriter.WriteLineAsync(new List\u003cstring\u003e{ \"One\", \"Two\\tTwo\", \"Three\" });\n    await tsvWriter.FlushAsync();\n}\n```\n\n# The `Linear TSV` format\n\n- Fields are separated by TAB characters\n- Text encoding is `UTF-8`\n- The reader can parse lines with any of these three endings: `\\n`, `\\r\\n`, `\\r`\n- The writer is restricted to output only the `\\n` character as EOL\n- Special characters inside the fields are replaced (both ways):\n  - Newline =\u003e `\"\\n\"`\n  - Carriage return =\u003e `\"\\r\"`\n  - Tab =\u003e `\"\\t\"`\n  - `\"\\\"` (backslash) =\u003e `\"\\\\\"`\n- The column counts are not validated, they can vary per line.\n\n# Benchmark\n\nThe benchmark test compares the performace of this library with \"native\" solutions, which use string replace operations. The solution with string replace (native) uses more memory and is slower than this library (lib). The benchmark test can be found here: [Benchmark.cs](Test/Benchmark.cs)\n\n|          Method |     Mean |   Error |  StdDev | Allocated |\n|---------------- |---------:|--------:|--------:|----------:|\n|     LibReadTest | 225.0 ms | 4.42 ms | 5.90 ms | 139.51 MB |\n|  NativeReadTest | 309.7 ms | 3.84 ms | 3.59 ms | 148.66 MB |\n|    LibWriteTest | 158.4 ms | 1.92 ms | 1.71 ms |   72.4 MB |\n| NativeWriteTest | 270.6 ms | 5.36 ms | 6.38 ms |  86.11 MB |\n\n# Configurations\n\nRun the unit tests: (You can also run them one-by-one from VS Code)\n```bash\n$ dotnet build -c Debug\n$ dotnet test\n```\n\nRun the benchmark:\n```bash\n$ dotnet run -c Release\n```\n\nCreate package for NuGet:\n```bash\n$ dotnet build -c Prod\n$ dotnet pack -c Prod\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolner%2Flineartsvparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbolner%2Flineartsvparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolner%2Flineartsvparser/lists"}