{"id":24769162,"url":"https://github.com/thyringer/cast","last_synced_at":"2026-02-02T09:45:44.495Z","repository":{"id":264130739,"uuid":"892344624","full_name":"thyringer/cast","owner":"thyringer","description":"CLI tool for reading strings or complex data sets from CSV files to output them in other text formats.","archived":false,"fork":false,"pushed_at":"2024-11-23T19:14:59.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T17:13:40.691Z","etag":null,"topics":["csv-converter","data","data-preprocessing","python","python3","sql-builder"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thyringer.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":"2024-11-21T23:58:10.000Z","updated_at":"2025-02-26T20:21:49.000Z","dependencies_parsed_at":"2024-11-22T07:37:13.453Z","dependency_job_id":null,"html_url":"https://github.com/thyringer/cast","commit_stats":null,"previous_names":["thyringer/cast"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyringer%2Fcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyringer%2Fcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyringer%2Fcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyringer%2Fcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thyringer","download_url":"https://codeload.github.com/thyringer/cast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074953,"owners_count":21043490,"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-converter","data","data-preprocessing","python","python3","sql-builder"],"created_at":"2025-01-29T02:47:36.725Z","updated_at":"2026-02-02T09:45:44.455Z","avatar_url":"https://github.com/thyringer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cast 1.0\n\nCast is a CLI tool for reading strings or complex data sets from CSV files to output them in other text formats.\n\nCast can also be used as a CLI interface for xxHash to generate hash values.\n\n## Outline of Functionalities\n\nThis Python script is a command line tool for generating SQL commands or other output with automatically hashed values using an algorithm of the xxHash family. The data to be processed is entered through the console or by reading in a text file. Furthermore, the printed results can be precisely formatted using templates.\n\nWhen reading CSV files, the column names are available as placeholders within the template, which allows the data records to be automatically converted into a suitable SQL insert command, for instance. In fact, any use case that requires automatic conversion to another text file format is conceivable.\n\n## CLI Setup\n\n1. Install Python interpreter (at least version 3.9).\n2. Satisfy dependency with `pip install xxhash`.\n\n### Linux\n\n1. Place program file `cast` (without Python extension `py`) under `~/local/bin` (Linux).\n\n2. In the hidden file `.bashrc` located in the user's home directory, write the following line of code,\n\n   `export PATH=$HOME/.local/bin:$PATH`\n\n   if this search path for executable scripts is not yet known.\n3. Make the script file executable with `chmod +x cast`.\n\n## Usage\n\n```bash\npython cast \u003cmode\u003e \u003cstrings\u003e [\u003coptions\u003e]\n```\nOr if stored in the local or system-wide bin folder as `xxh`:\n\n```bash\ncast [\u003cmode\u003e] \u003cstrings\u003e [\u003coptions\u003e]\n```\n\nThe first parameter specifies the algorithm, with the following options available:\n\n- `   32` → `xxh32` \n- `   64` → `xxh64`\n- ` 3_64` → `xxh3_64` \n- `3_128` → `xxh3_128`\n- ` uuid` → hexadecimal digest of  `xxh3_128` formated as a UUID\n\nIn addition, each algorithm has a variant for a hexadecimal number `32x` and an unsigned integer `s32` as a result (which can be particularly useful in the context of PostgreSQL, since there are only signed integers available).\n\nBy default, `64` is assumed.\n\n### Options\n\n-  `--read` / `-r`\n\n  Load file, where each line is treated as a string to be hashed. If a CSV file is present, the hash value is calculated from all columns separated by commas, unless `--input` is used to specify exactly which columns should be hashed and how. For this reason, the program assumes that CSV files have a table header.\n\n- `--write` / `-w`\n\n  Specify the file in which the results should be written instead of outputting them to the console. If the specified file does not yet exist, it will be created automatically.\n\n- `--input` / `-i`\n\n  Template with the placeholder `{string}`, which specifies how strings are to be hashed. When a CSV file is read in, individual column values can also be addressed using their column names as placeholders.\n\n- `--output` / `-o`\n\n  Template to specify exactly how records are to be output, with the possible placeholders `{string}`, `{input}`, `{hash}`, but also all column names of a read CSV file, where spaces between words are to be replaced by underscores. By default, `\"{input}\" =\u003e {hash}` is used as a template; for CSV files, however, an additional column for the generated hash values is added at the beginning.\n\n- `--template` / `-t`\n\n  The overall output can be defined using another template, where the placeholder `{records}` stands for all records.\n\n- `--spacing` / `-s`\n\n  This allows additional characters to be inserted between the individual records, by default a simple line break `\"\\n\"`.\n\n**Important Note**\n\nIn order for Bash to interpret line breaks as in `\";\\n\"`, such strings must be written as `$';\\n'`.\n\n## Examples\n\nInput with Default Settings:\n\n```bash\ncast 64 \"Hello, world!\" \"This is a test string.\"\n```\n\nOutput in Custom Format:\n\n```bash\ncast 64 \"Hello, world!\" \"This is a test.\" -o \"'{input}': {hash}\"\n```\n\n**Generate an SQL insert command with records from a CSV data**\n\nBy specifying a template, an insert command can be generated:\n\n```bash\ncast 32s \\\n\t-r capitals.csv \\\n\t-w capitals.sql \\\n\t-i \"{country_code},{capital_city}\" \\\n\t-o \"({hash}, '{country_code}', '{capital_city}')\" \\\n\t-t $'insert into City\\n\\t(hash, country, capital)\\nvalues\\n\\t{records};\\n' \\\n\t-s $'\\n\\t' \\\n```\n\nAnd with this CSV file as dataset,\n\n```csv\ncapital city, country code, country\nWashington D.C., US, United States\nOttawa, CA, Canada\nBerlin, DE, Germany\nTokyo, JP, Japan\nCanberra, AU, Australia\nParis, FR, France\nBrasília, BR, Brazil\nMoscow, RU, Russia\nBeijing, CN, China\nNew Delhi, IN, India\n```\n\nthe following output is generated:\n\n```sql\ninsert into City\n\t(hash, country, capital)\nvalues\n\t(1507852509, 'US', 'Washington D.C.')\n\t(2050315825, 'CA', 'Ottawa')\n\t(-1405512320, 'DE', 'Berlin')\n\t(1261058448, 'JP', 'Tokyo')\n\t(1366882969, 'AU', 'Canberra')\n\t(-1994286539, 'FR', 'Paris')\n\t(1797318940, 'BR', 'Brasília')\n\t(2116051181, 'RU', 'Moscow')\n\t(-711255517, 'CN', 'Beijing')\n\t(1246361623, 'IN', 'New Delhi');\n```\n\n## Dependencies\n\nA Python interpreter version 3.9 or higher is expected. Furthermore, the following dependency must be installed using pip:\n\n```bash\npip install xxhash\n```\n\n## License\n\nSource code is public domain.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthyringer%2Fcast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthyringer%2Fcast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthyringer%2Fcast/lists"}