Last active
October 24, 2016 13:20
-
-
Save itochu0523/791f1443a124d1e161dede0e913f18bf to your computer and use it in GitHub Desktop.
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
| #!/bin/sh | |
| # | |
| # td command option | |
| # -d : database name | |
| # -w : waiting | |
| # --output : output file name to local | |
| # -f : file format | |
| # -c : add column name (top line) | |
| mode=$1 | |
| while read table | |
| do | |
| echo "$table" | |
| if [ $mode = "add_header" ]; then | |
| td query -d sample_datasets 'select count(1) from $table' -w -T presto --output test.csv -f csv -c | |
| mv test.csv test_tmp.csv | |
| cat '$table'.csv test_tmp.csv >> '$table'.csv | |
| rm test_tmp.csv | |
| else | |
| td query -d sample_datasets 'select count(1) from $table' -w -T presto --output test.csv -f csv | |
| mv test.csv test_tmp.csv | |
| cat test_tmp.csv > '$table'.csv | |
| rm test_tmp.csv | |
| fi | |
| done < table_list.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment