rawmerger: write_table_all() for direct csv output of merged table

This commit is contained in:
Mario Fink 2020-08-13 16:01:54 +02:00
parent 0bd96a1426
commit 4ce51b55c7
4 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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 )

View File

@ -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=",")
#-----------------------------------------------------------------------------#