I currently have the function below which has an if-else
statement within it. After reading this post I thought it may be better to use try-catch
Exception Handling instead. However, I am not sure how to do this. Basically, if the currency
inputted is not AUD
I want to throw an Exception with the print
statement below.
def update(self, currency):
if self.currency == 'AUD':
url = 'http://www.rba.gov.au/statistics/tables/csv/f17-yields.csv'
response = urllib2.urlopen(url)
text = response.read()
csvfile = StringIO.StringIO(text)
df = pd.read_csv(csvfile)
print df
else:
print('This currency is not available in Database')