{"id":30226300,"url":"https://github.com/kawasin73/nested_csv","last_synced_at":"2026-04-16T00:32:55.069Z","repository":{"id":57445535,"uuid":"217898927","full_name":"kawasin73/nested_csv","owner":"kawasin73","description":"CSV generator for nested dict or list data structure such as JSON","archived":false,"fork":false,"pushed_at":"2019-10-27T18:58:55.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-26T02:18:45.220Z","etag":null,"topics":["csv","json","python"],"latest_commit_sha":null,"homepage":null,"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/kawasin73.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":"2019-10-27T18:35:46.000Z","updated_at":"2021-05-03T21:50:51.000Z","dependencies_parsed_at":"2022-09-26T17:30:52.595Z","dependency_job_id":null,"html_url":"https://github.com/kawasin73/nested_csv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kawasin73/nested_csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawasin73%2Fnested_csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawasin73%2Fnested_csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawasin73%2Fnested_csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawasin73%2Fnested_csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kawasin73","download_url":"https://codeload.github.com/kawasin73/nested_csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawasin73%2Fnested_csv/sbom","scorecard":{"id":552063,"data":{"date":"2025-08-11","repo":{"name":"github.com/kawasin73/nested_csv","commit":"c8d983b5889994c92d3765f283cfb3f54c5ff573"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/1 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/kawasin73/nested_csv/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/kawasin73/nested_csv/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:32","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T11:08:59.528Z","repository_id":57445535,"created_at":"2025-08-20T11:08:59.528Z","updated_at":"2025-08-20T11:08:59.528Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31866347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"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","json","python"],"created_at":"2025-08-14T16:07:47.180Z","updated_at":"2026-04-16T00:32:55.049Z","avatar_url":"https://github.com/kawasin73.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nested_csv\n\n[![Actions Status](https://github.com/kawasin73/nested_csv/workflows/Python%20package/badge.svg)](https://github.com/kawasin73/nested_csv/actions)\n\nnested_csv generates CSV from nested `dict` `list` data structure such as JSON.\n\n`nested_csv.NestedDictWriter` have same interface (`writerow`, `writerows`, `writeheader`) with `csv.DictWriter`.\n\n## Install\n\n```bash\n$ pip install nested-csv\n```\n\n## Dependency\n\nnested_csv requires Python 3.\n\nnested_csv only use standard packages (`csv`, `itertools`, `re`).\n\n## How to Use\n\n### Estimate fields\n\n```python\nfrom nested_csv import generate_fieldnames\ndata = [\n  {\"hello\": {\"world\": \"value0\"}, \"list\": [[1,2,3], [4,5,6]], \"fixed\": [1,2]},\n  {\"hello\": {\"world\": \"value1\"}, \"list\": [[7,8], [10,11]], \"fixed\": [3,4]},\n]\nfieldnames = generate_fieldnames(data[0])\n# ['fixed[id]', 'fixed[]', 'hello.world', 'list[id]', 'list[][id]', 'list[][]']\n```\n\n### Generate Nested CSV\n\n```python\nimport io\nfrom nested_csv import NestedDictWriter\ndata = [\n  {\"hello\": {\"world\": \"value0\"}, \"list\": [[1,2,3], [4,5,6]], \"fixed\": [1,2]},\n  {\"hello\": {\"world\": \"value1\"}, \"list\": [[7,8], [10,11]], \"fixed\": [3,4]},\n]\nfieldnames = ['hello.world', 'list[id]', 'list[][id]', 'list[][]', 'fixed[1]']\nfile = io.StringIO()\nw = NestedDictWriter(file, fieldnames)\nw.writeheader()\nw.writerows(data)\nfile.seek(0)\nfile.read()\n# hello.world,list[id],list[][id],list[][],fixed[1]\n# value0,0,0,1,2\n# value0,0,1,2,2\n# value0,0,2,3,2\n# value0,1,0,4,2\n# value0,1,1,5,2\n# value0,1,2,6,2\n# value1,0,0,7,4\n# value1,0,1,8,4\n# value1,1,0,10,4\n# value1,1,1,11,4\n```\n\n## Field Format\n\nYou can generate fields format automatically by using `generate_fieldnames()`.\n\nBut `generate_fieldnames()` is sometimes not appropriate when ...\n\n- the order of csv row is important\n  - `generate_fieldnames()` will generate fields ordered by lexical order\n- the base object includes length list\n  - `generate_fieldnames()` can't estimate the scheme of empty object\n\nPlease set fieldnames manually on those situations.\n\nThe format of fieldnames is following.\n\n### nested keys\n\nNested dict key is joined by `.` (dot).\n\n```\nJSON : {\"a\": {\"b\": 1, \"c\": 2}}\nformat : [\"a.b\", \"a.c\"]\n--- CSV ---\n1,2\n```\n\n### id support\n\n`NestedDictWriter` will insert `id` passed on `writerow(rowdict, id=0)` or `writerows(rowdicts, first_id=0)`.\n\n```\nJSON : {\"a\": {\"b\": 1, \"c\": 2}}\nformat : [\"id\", \"a.b\", \"a.c\"]\n--- CSV ---\n0,1,2\n```\n\n### fixed size list\n\nWhen the size of the list is known, list elements can be specified by index `[\u003cindex number\u003e]`.\n\n```\nJSON : {\"a\": [1,2], \"b\": [0]}\nformat : [\"a[0]\", \"a[1]\", \"b[0]\"]\n--- CSV ---\n1,2,0\n```\n\n### list\n\n`NestedDictWriter` unfolds the list elements into multiple rows when specified by `[]`.\n\nNested list is also supported.\n\nThe level of each list must match.\n\n- Bad Cases\n  - `\"a[]\"` + `\"a.b\"` : key and list at same level\n  - `\"a[]\"` + `\"b.c[]\"` : list level not match\n  - `\"a[][]\"` + `\"b[].c[]\"` : sub list level not match\n\nThe count of unfolding loop is maximum length of list at each level. If list size is shorter than maximum, the value of exceeded index is empty.\n\n```\nJSON : {\"a\": [[{\"x\": 1}], [{\"x\": 2}, {\"x\": 3}]], \"b\": [4, 5, 6], \"c\": [[7, 8, 9]]}\nformat : [\"a[][].x\", \"b[]\", \"c[][]\"]\n--- csv ---\n1,4,7\n,4,8\n,4,9\n2,5,\n3,5,\n,5,\n,6,\n,6,\n,6,\n```\n\n### list index\n\nThe unfolding loop index of list is specified by `[id]`.\n\n```\nJSON: {\"a\": [[1,2,3], [4,5]}\nformat : [\"a[id]\", \"a[][id]\", \"a[][]\"]\n--- csv ---\n0,0,1\n0,1,2\n0,2,3\n1,0,4\n1,1,5\n1,2,\n```\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawasin73%2Fnested_csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkawasin73%2Fnested_csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawasin73%2Fnested_csv/lists"}