Iterates over the saved data from the ETL routine, selecting the following columns: 'Employer', 'Lang', 'Date', 'Shortest Sentence', 'Longest Sentence', 'Words', 'Readability Consensus'. These are then saved as a table, in Markdown format, in 'table.md'.
# Data handling, structures and analysis tools, SQLite database interface
import pandas as pd
import sqlite3
# Default options
x_variable = 'modification_date'
# Read database, attach as Pandas dataframe sorted by date
db = sqlite3.connect("Data/Applications.db")
columns = 'Title, Readability, Words, Sentences, Interview, Offer, Reply, modification_date'
df = pd.read_sql_query('SELECT ' + columns + ' FROM applications ORDER BY Date(' + x_variable + ') DESC', db)
db.close()
# Cast `modification_date` as DateTime, then drop `modification_date`-column
df['Date'] = pd.to_datetime(df['modification_date'], unit='s')
df = df.drop('modification_date', 1)
df.head()
# Parse Dataframe and apply Markdown
cols = df.columns
df2 = pd.DataFrame([['---','---','---','---','---','---','---','---']], columns=cols)
df3 = pd.concat([df2, df])
# Save table to .md-file
try:
df3.to_csv('Data/table.md', sep="|", index=False)
pass
except IOError as e:
print (e)
pass
finally:
print ('Saved Data/table.md.')