Esempio n. 1
0
def main():
# Q7
	import_and_transform('../indicator gapminder gdp_per_capita_ppp.xlsx')
	try:
		while True:
			print '\n You have three options'
			print '\n 1. Please input a year between 1800 and 2012 to generate plots'
			print '\n 2. Please enter finish to exit plotting and generate graphs for the years 2007-2012'
			print '\n 3. Please enter quit to exit this program\n'
			x = raw_input()
			if x == 'finish':
				break

			elif x == 'quit':
				sys.exit()

			elif re.match(r"^[0-9]{4}$", x):
				try:
					plot_income_by_yr(int(x))
				except KeyError:
					print '\n Input Error: Invalid Year!\n'

			else:
				print "\n Input Error: Please a valid year!\n"

	# Q8
		print '\n Generating plots......'
		yr_list = range(2007, 2013)
		for yr in yr_list:
			result = vs.visualize_tool(yr)	# use visulize tool class to generate plot
			result.plot_boxplot()
			result.plot_hist()
		print '\n Plots are saved at current dictionary'

	except KeyboardInterrupt, ValueError:
		print "\n Interrupted!"
Esempio n. 2
0
 def test_plot_income_by_yr_2(self):
     with self.assertRaises(KeyError) as cm:
         hw9_functions.plot_income_by_yr(1000)
     the_exception = cm.exception
     self.assertEquals(str(the_exception), "'Invalid Year!'")