twitools/datecsv.sh

16 lines
483 B
Bash
Raw Normal View History

#!/bin/bash
DATAFILE=Database.db
SQLITE="sqlite3 -csv -header"
QUERY="SELECT SUBSTR(t.timestamp,0,11) AS 'Date', (SELECT COUNT(*) FROM tweets e WHERE SUBSTR(e.timestamp,0,11) = SUBSTR(t.timestamp,0,11)) AS 'Tweets'"
for i in $@;
do QUERY="$QUERY, (SELECT COUNT(*) FROM tweets e WHERE SUBSTR(e.timestamp,0,11) = SUBSTR(t.timestamp,0,11) AND LOWER(e.text) LIKE '%${i,,}%') AS '$i'"
done
QUERY="$QUERY FROM tweets t GROUP BY SUBSTR(t.timestamp,0,11);"
$SQLITE $DATAFILE "$QUERY"