Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Standard Chartered Bank Singapore Bank CSV download cleaner
import pandas as pd
import numpy as np
import sys
# Create a Dataframe from CSV
df = pd.read_csv(sys.argv[1], thousands = ',', delimiter = ',', skiprows = 5, low_memory = False, keep_default_na = False)
# Cleaning: (1) Tabs in columns and headers (2) Make numbers into numbers instead of strings
df.columns = df.columns.str.strip()
df.Date = df.Date.str.strip()
df['Withdrawal'] = '-' + df['Withdrawal'].astype(str)
df['Withdrawal'] = df.Withdrawal.replace(r'-', np.nan)
# Write to file
df.to_csv('clean_' + sys.argv[1], index = False, float_format = '%.2f', encoding = 'utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.