Created
April 10, 2018 10:15
-
-
Save haranjackson/0689d831a86f691678952b5cf45047dd to your computer and use it in GitHub Desktop.
Convert a Revolut HTML statement into a Pandas dataframe
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
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