import csv

def datasheet(data, results_dir):
	"""
	data = [{lats: [...], lons: [...], times: [...]}, ...]
	"""
	stp_num = len(data)
	print 'datasheeting %d trajectories...' %stp_num
	csvData = []

	for i in range(stp_num):
		lats = data[i]['lats']
		lons = data[i]['lons']
		times = data[i]['times']
		csvData.append(['Trajectory %d'%(i+1)])
		for j in range(len(lats)):
			csvData.append([times[j], lats[j], lons[j]])

	f = open(results_dir+'/output.csv', 'w')
	w = csv.writer(f)
	w.writerows(csvData)
	f.close()

	print 'datasheeting done'