From 4ce51b55c79ee8074345fad1c573829620550022 Mon Sep 17 00:00:00 2001 From: Mario Fink Date: Thu, 13 Aug 2020 16:01:54 +0200 Subject: [PATCH] rawmerger: write_table_all() for direct csv output of merged table --- cyt/raw_meat.pxd | 2 ++ cyt/raw_meat.pyx | 3 +++ lib/rawmerge.hpp | 2 +- pyt/example.py | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cyt/raw_meat.pxd b/cyt/raw_meat.pxd index deed773..56e12c5 100644 --- a/cyt/raw_meat.pxd +++ b/cyt/raw_meat.pxd @@ -33,3 +33,5 @@ cdef extern from "../lib/rawmerge.hpp": vector[double] get_channel(int) # get total merged time series vector[double] get_time_series() + # dump all channels to .csv + void write_table_all(const char*,char) diff --git a/cyt/raw_meat.pyx b/cyt/raw_meat.pyx index c1b140b..ec6ab5c 100644 --- a/cyt/raw_meat.pyx +++ b/cyt/raw_meat.pyx @@ -53,3 +53,6 @@ cdef class rawmerger: def get_time_series(self): return self.rawit.get_time_series() + + def write_table_all(self, const char* csvfile, char delimiter): + return self.rawit.write_table_all(csvfile,delimiter) diff --git a/lib/rawmerge.hpp b/lib/rawmerge.hpp index d802372..0265771 100644 --- a/lib/rawmerge.hpp +++ b/lib/rawmerge.hpp @@ -296,7 +296,7 @@ public: } // print all data to file - void write_table(std::string filename, char delimiter = ',', int precision = 6, int width = 25) + void write_table_all(std::string filename, char delimiter = ',', int precision = 6, int width = 25) { // if at least one channel including its time series is present if ( timeseries_.size() > 0 && channels_.size() > 0 ) diff --git a/pyt/example.py b/pyt/example.py index 6c5b82d..994d10c 100644 --- a/pyt/example.py +++ b/pyt/example.py @@ -83,6 +83,9 @@ for rf in rawlist : # show summary of successfully merged channels print("\nmerged channels:\n") +# write merged table to .csv output +eatmea.write_table_all('allchannels.csv'.encode(),ord(',')) + # get number of successfully merged channels and their names (+units) numch = eatmea.get_num_channels() chnames = [chnm.decode(encoding='UTF-8',errors='ignore') for chnm in eatmea.get_channel_names()] @@ -118,6 +121,6 @@ pq.write_table(pyarwtab,'allchannels.parquet',compression='BROTLI') # compressi # try to read and decode the .parquet file df = pq.read_table('allchannels.parquet') print(df.to_pandas()) -df.to_pandas().to_csv('allchannels.csv',index=False,encoding='utf-8',sep=",") +# df.to_pandas().to_csv('allchannels.csv',index=False,encoding='utf-8',sep=",") #-----------------------------------------------------------------------------#