Skip to content

Instantly share code, notes, and snippets.

@zseta
Created April 21, 2024 15:53
Show Gist options
  • Save zseta/6b89df855e5789c16e1bfc6c4cfb5ca4 to your computer and use it in GitHub Desktop.
Save zseta/6b89df855e5789c16e1bfc6c4cfb5ca4 to your computer and use it in GitHub Desktop.
Working with large CSV files in Linux to generate database schema

Output the first N numer of rows from a csv into another:

head -n 5 data.csv > header.csv

Generate schema from csv

pip install csvkit

csvsql -d "," -q '"' -i postgresql spotifyschema.csv > spotify_schema.sql
  • -d DELIMETER
  • -q QUOTE CHARACTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment