From c447d045beaf271b822411beb620ad1794d6498f Mon Sep 17 00:00:00 2001 From: Ryan Zotti Date: Sun, 9 Oct 2016 17:16:42 -0400 Subject: [PATCH] writes to csv via pandas and is somewhat faster --- npz_to_h2o_csv.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/npz_to_h2o_csv.py b/npz_to_h2o_csv.py index fc39e57e..3aa793a6 100644 --- a/npz_to_h2o_csv.py +++ b/npz_to_h2o_csv.py @@ -36,10 +36,7 @@ def separate_by_commas(row): flat_data = predictors.reshape([record_count,240*320*3]) flat_data = np.concatenate((flat_data, targets_np), axis=1) flat_data = pd.DataFrame(flat_data) - for row in flat_data.iterrows(): - with open(output_data_path,'a') as file_writer: - line = separate_by_commas(row[1]) # first element is just a pandas index - file_writer.write(line) + flat_data.to_csv(path_or_buf=data_path + '/' + folder + '/h2o_train.csv') print("Processed "+str(folder)) print("Finished.")