diff options
author | Étienne Simon <esimon@esimon.eu> | 2015-05-18 18:57:08 -0400 |
---|---|---|
committer | Étienne Simon <esimon@esimon.eu> | 2015-05-18 18:57:08 -0400 |
commit | 4f68132cc9c62860bd3368e559e430961c872636 (patch) | |
tree | 275554a1abcd419d0c477b639dcbd50189d3245d /test.py | |
parent | 6d946f29f7548c75e97f30c4356dbac200ee6cce (diff) | |
download | taxi-4f68132cc9c62860bd3368e559e430961c872636.tar.gz taxi-4f68132cc9c62860bd3368e559e430961c872636.zip |
Use os.path.join and close files
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -28,11 +28,11 @@ if __name__ == "__main__": model.set_param_values(parameters) if 'destination' in outputs: - dest_outfile = open("output/test-dest-output-%s.csv" % model_name, "w") + dest_outfile = open(os.path.join('output', 'test-dest-output-%s.csv' % model_name), 'w') dest_outcsv = csv.writer(dest_outfile) dest_outcsv.writerow(["TRIP_ID", "LATITUDE", "LONGITUDE"]) if 'duration' in outputs: - time_outfile = open("output/test-time-output-%s.csv" % model_name, "w") + time_outfile = open(os.path.join('output', 'test-time-output-%s.csv' % model_name), 'w') time_outcsv = csv.writer(time_outfile) time_outcsv.writerow(["TRIP_ID", "TRAVEL_TIME"]) @@ -46,3 +46,8 @@ if __name__ == "__main__": if 'duration' in outputs: duration = output_values[outputs.index('duration')] time_outcsv.writerow([d['trip_id'][0], duration[0]]) + + if 'destination' in outputs: + dest_outfile.close() + if 'duration' in outputs: + time_outfile.close() |