-
-
Save mattwigway/241d8b30f07dcaa8059242f9e6528310 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
# Load the file referenced in the first argument into a Jupyter QtConsole as df | |
# change to appropriate conda environment | |
source activate py37 | |
tempscript=`mktemp` | |
tee "$tempscript" <<EOF | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# triple quotes for safety | |
filename = '''$1''' | |
if filename.endswith('.csv'): | |
df = pd.read_csv(filename) | |
elif filename.endswith('.tsv'): | |
df = pd.read_csv(filename, sep='\t') | |
elif filename.endswith('.xls') or filename.endswith('.xlsx'): | |
df = pd.read_excel(filename) | |
elif filename.endswith('.dta'): | |
df = pd.read_stata(filename) | |
elif filename.endswith('.feather'): | |
df = pd.read_feather(filename) | |
else: | |
raise ValueError(f'cannot determine file type of {filename}!') | |
EOF | |
PYTHONSTARTUP=$tempscript jupyter qtconsole | |
rm $tempscript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment