#!/usr/bin/env python
import os

import requests


# local configuration
remote_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'data', 'remote')


# URLs at which data can be found
csv_url_summary_stats = 'http://dashboard.iatistandard.org/summary_stats.csv'
csv_url_humanitarian_stats = 'http://dashboard.iatistandard.org/humanitarian.csv'


with open(os.path.join(remote_data_path, 'summary_stats.csv'), 'wb') as f:
	# load the data to write to the file
	# TODO: Add error handling - URL loading
	response = requests.get(csv_url_summary_stats)

	if not response.ok:
		print('There was a problem loading the Summary Statistics data')

	# TODO: Add error handling - file writing
	f.write(response.text.encode('utf-8'))


with open(os.path.join(remote_data_path, 'humanitarian.csv'), 'wb') as f:
	# load the data to write to the file
	# TODO: Add error handling - URL loading
	response = requests.get(csv_url_humanitarian_stats)

	if not response.ok:
		print('There was a problem loading the Summary Statistics data')

	# TODO: Add error handling - file writing
	f.write(response.text.encode('utf-8'))



# TODO: Add mention of __main__ and main()

#!/usr/bin/env python
import os

import requests


# local configuration
remote_data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'data', 'remote')


# URLs at which data can be found
csv_url_summary_stats = 'http://dashboard.iatistandard.org/summary_stats.csv'
csv_url_humanitarian_stats = 'http://dev.dashboard.iatistandard.org/humanitarian.csv'


with open(os.path.join(remote_data_path, 'summary_stats.csv'), 'wb') as f:
	# load the data to write to the file
	# TODO: Add error handling - URL loading
	response = requests.get(csv_url_summary_stats)

	if not response.ok:
		print('There was a problem loading the Summary Statistics data')

	# TODO: Add error handling - file writing
	f.write(response.text.encode('utf-8'))


with open(os.path.join(remote_data_path, 'humanitarian.csv'), 'wb') as f:
	# load the data to write to the file
	# TODO: Add error handling - URL loading
	response = requests.get(csv_url_humanitarian_stats)

	if not response.ok:
		print('There was a problem loading the Humanitarian Statistics data')

	# TODO: Add error handling - file writing
	f.write(response.text.encode('utf-8'))


# TODO: Add mention of __main__ and main()

Set a URL to download the humanitarian CSV from
Set a URL to download the humanitarian CSV from

and fix a copypaste error
