{"id":20550407,"url":"https://github.com/dnmfarrell/bash-csv","last_synced_at":"2026-04-20T02:33:23.748Z","repository":{"id":149703502,"uuid":"437031131","full_name":"dnmfarrell/bash-csv","owner":"dnmfarrell","description":"Bash library to parse csv strings into an array","archived":false,"fork":false,"pushed_at":"2021-12-10T15:46:39.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T05:44:14.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnmfarrell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-12-10T15:46:31.000Z","updated_at":"2021-12-14T04:15:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"648e9a06-1f3a-4671-852d-93383793e720","html_url":"https://github.com/dnmfarrell/bash-csv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dnmfarrell/bash-csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Fbash-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Fbash-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Fbash-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Fbash-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnmfarrell","download_url":"https://codeload.github.com/dnmfarrell/bash-csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Fbash-csv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27558646,"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","status":"online","status_checked_at":"2025-12-07T02:00:07.896Z","response_time":53,"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":[],"created_at":"2024-11-16T02:24:53.702Z","updated_at":"2025-12-07T02:02:27.847Z","avatar_url":"https://github.com/dnmfarrell.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Bash CSV Parser\n---------------\nThis repo provides a bash library called `csv.bash` which parses lines of comma-delimited-values into an array.\n\nHere's `example/parse-stdin.bash`:\n\n    #!/bin/bash\n    source csv.bash                   # load the library\n    while IFS= read -r CSV_ROW;do     # read stdin line by line into CSV_ROW\n      csv_row_to_cols                 # parse CSV_ROW into CSV_COLS\n      printf \"%s\\n\" \"${CSV_COLS[@]}\"  # do something with CSV_COLS!\n    done\n\nIt reads a stream of csv input and prints each parsed column on a new line. `csv_row_to_cols` parses the global variable `CSV_ROW` and populates the results in `CSV_COLS` (returning values via globals is necessary in bash).\n\n    echo 'foo,\"bar,baz\",,\"boo\\\"\",' | example/parse-stdin.bash\n    foo\n    \"bar,baz\"\n    \"\"\n    \"boo\\\"\"\n    \"\"\n\nThis example shows the default behavior, but that can be changed by setting these global variables:\n\n    CSV_TER=\"\"    # terminator for rows\n    CSV_DEL=\",\"   # delimiter for columns\n    CSV_QUO='\"'   # quote char - quoted delimiters are ignored\n    CSV_ESC=\"\\\\\"  # escape char for quote char\n    CSV_CON=1     # consecutive delimiters declare empty columns\n    CSV_EMP='\"\"'  # empty column replacement value\n\nFor example you can set `CSV_DEL` to tab to parse tab-delimited data. Less obviously, you could use `csv.bash` to read command arguments from input and split them into words, instead of using `xargs`, which is slow.\n\n    #/bin/bash\n    source csv.bash\n    CSV_DEL=\" \"\n    CSV_ROW='foo \"bar baz\"' # bash will wordsplit like this (foo,\"bar,baz\")\n    csv_row_to_cols         # CSV_COLS=(foo,\"bar baz\")\n    ...\n\nAll global variables are prepended with `CSV_` to avoid name clashes with other code. And that's not all the global variables either! `CSV_COLC` is set to the number of columns parsed, which is handy to use as the length of `$CSV_COLS` which bash may not report correctly if it contains empty strings. `CSV_ROWC` is an incrementing row counter, which you may want to reset to 0 if your code is parsing different inputs in the same process.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Fbash-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnmfarrell%2Fbash-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Fbash-csv/lists"}