{"repo":"simonw/csvs-to-sqlite","free":true,"listed":false,"github":"https://github.com/simonw/csvs-to-sqlite","clone":"git clone https://github.com/simonw/csvs-to-sqlite.git","description":"Convert CSV files into a SQLite database","language":"Python","stars":937,"topics":["sqlite","python","csv","pandas","click","datasette","datasette-io","datasette-tool"],"license":"Apache-2.0","category":"databases-storage","readme_excerpt":"csvs-to-sqlite Convert CSV files into a SQLite database. Browse and publish that SQLite database with Datasette. [!NOTE] This tool is infrequently maintained . I suggest using sqlite-utils for importing CSV and TSV to SQLite instead for most cases. Basic usage: This will create a new SQLite database called mydatabase.db containing a single table, myfile , containing the CSV content. You can provide multiple CSV files: The bundle.db database will contain two tables, one and two . This means you can use wildcards: If you pass a path to one or more directories, the script will recursively search those directories for CSV files and create tables for each one. Handling TSV (tab-separated values) You can use the -s option to specify a different delimiter. If you want to use a tab character you'll need to apply shell escaping like so: Refactoring columns into separate lookup tables Let's say you have a CSV file that looks like this: (Real example taken from the Open Elections project) You can now convert selected columns into separate lookup tables using the new --extract-column option (shortname: -c ) - for example: The format is as follows: If you just specify the column name e.g. -c office , the following table will be created: If you specify all three options, e.g. -c precinct:Precinct:name the table will look like this: The original tables will be created like this: They will be populated with IDs that reference the new derived tables. Installation csvs-to-sqlite now requires P","default_branch":null,"files":null,"tree":[],"storefront":"/r/simonw","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/simonw/csvs-to-sqlite/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}