Skip to content

Instantly share code, notes, and snippets.

View susodapop's full-sized avatar

Jesse susodapop

View GitHub Profile
@susodapop
susodapop / cloner.py
Last active February 26, 2020 22:23 — forked from arikfr/redash.py
Edited to allow dashboard clone that forks the underlying queries
from redash import Redash
# Enter your user API key, Redash URL, and the URL slug for your target dashboard
API_KEY = ''
REDASH_URL = 'https://app.redash.io/<your organization slug>'
DASHBOARD_SLUG = ''
redash = Redash(REDASH_URL, API_KEY)
dash = redash.fork_dashboard_and_queries(DASHBOARD_SLUG)
@susodapop
susodapop / redash_csv_to_query.py
Created August 16, 2019 12:57
Use this snippet to convert an input CSV file into a query for Redash. This is nifty if you can't host your CSV. This only works with up to 500 rows of data, so it's a bit of an edge case.
import csv
import re
import string
with open('MOCK_DATA.csv', newline='\n', encoding="cp437") as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
headers = spamreader.__next__();
pat = re.compile = r"'"
repl = r"''"