Skip to content

Instantly share code, notes, and snippets.

@haranjackson
Created April 10, 2018 10:15
Show Gist options
  • Save haranjackson/0689d831a86f691678952b5cf45047dd to your computer and use it in GitHub Desktop.
Save haranjackson/0689d831a86f691678952b5cf45047dd to your computer and use it in GitHub Desktop.
Convert a Revolut HTML statement into a Pandas dataframe
from pandas import read_csv
# Enter path to file here
fname = ''
def convert_to_floats(col):
return col.apply(lambda x: float(x.replace(',', '')) if x != '' else 0)
with open(fname, 'r') as f:
df = read_csv(f, sep=';')
df.columns = df.columns.str.strip()
df = df.applymap(lambda x: x.strip() if type(x) is str else x)
df['Paid Out (GBP)'] = convert_to_floats(df['Paid Out (GBP)'])
df['Paid In (GBP)'] = convert_to_floats(df['Paid In (GBP)'])
df['Balance (GBP)'] = convert_to_floats(df['Balance (GBP)'])
paidIn = df['Paid In (GBP)'].sum()
paidOut = df['Paid Out (GBP)'].sum()
netIn = paidIn - paidOut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment