From adf52e857b98502bb2f489cc10ea739889d9c155 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Wed, 18 Nov 2020 09:54:31 -0300 Subject: [PATCH] write function changed --- yoshi-seals1.3.3/Seals/write/write.py | 36 ++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/yoshi-seals1.3.3/Seals/write/write.py b/yoshi-seals1.3.3/Seals/write/write.py index b9bd1e9..a2b9461 100644 --- a/yoshi-seals1.3.3/Seals/write/write.py +++ b/yoshi-seals1.3.3/Seals/write/write.py @@ -18,16 +18,34 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import csv +import numpy as np +import pandas as pd -def numpy(array, path): +class numpy: - with open(path, mode='w') as sistema_linear: + def __init__(self): + pass + def csv(self, array, path): - solution_writer = csv.writer(sistema_linear, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) - solution_writer.writerows(array) - - return array + with open(path, mode='w') as sistema_linear: -def pandas(df, path): - - df.to_csv(path) \ No newline at end of file + solution_writer = csv.writer(sistema_linear, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) + solution_writer.writerows(array) + + def txt(self, array, path): + + np.savetxt(path, array, fmt='%8f', delimiter=' ', \ + newline='\n', header='', footer='', comments='# ', encoding=None) + +class pandas: + + def __init__(self): + pass + def csv(self, df, path): + + df.to_csv(path) + + def txt(self, df, path): + + np.savetxt(path, df.values, fmt='%8f', delimiter=' ', \ + newline='\n', header='', footer='', comments='# ', encoding=None) \ No newline at end of file