Last active
July 10, 2018 13:24
-
-
Save filimonov/57e270104a3e48d7fd6f70a3d4ec2b95 to your computer and use it in GitHub Desktop.
Reformat CSV to clickhouse-compatible TSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv, sys | |
csv.register_dialect('clickhouse', escapechar="\\", doublequote=0, quotechar='\'',skipinitialspace = 0,delimiter = '\t', quoting=csv.QUOTE_NONE, lineterminator='\n') | |
csv.writer(sys.stdout, dialect='clickhouse').writerows(csv.reader(sys.stdin)) | |
# install: | |
# put in $PATH | |
# chmod +x csv2tsv.py | |
# usage: | |
# cat file.csv | csv2tsv.py | clickhouse-client ... --query='INSERT ...' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment