diff --git a/README.md b/README.md index 24331ab..c1f8cf2 100644 --- a/README.md +++ b/README.md @@ -275,9 +275,13 @@ to simply extract all data of the TDM datatset and dump it to files in a given ```Python import tdm_reaper jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') -jack.write_all(b"./my_tdm_data/") +jack.write_all(b"./my_tdm_data_directory/") ``` +The interface allows to construct customized file/column headers from any +meta-data and provide these headers for usage in file output (for an example +see [customized filehader](python/custom.py)). + ## References ### TDM diff --git a/cython/py_tdm_reaper.pyx b/cython/py_tdm_reaper.pyx index 89badb4..3866db3 100644 --- a/cython/py_tdm_reaper.pyx +++ b/cython/py_tdm_reaper.pyx @@ -36,9 +36,9 @@ cdef class tdmreaper: return jn.loads(chnstr.decode()) # print a channel(-group) - def print_channelgroup(self, string id, const char* filename, - bool include_meta, char delimiter): - self.cpp_tdm.print_group(id,filename,include_meta,delimiter) + def print_channelgroup(self, string id, const char* filename, bool include_meta, + char delimiter, string column_header): + self.cpp_tdm.print_group(id,filename,include_meta,delimiter,column_header) def print_channel(self, string id, const char* filename, bool include_meta): self.cpp_tdm.print_channel(id,filename,include_meta) @@ -48,4 +48,4 @@ cdef class tdmreaper: grpids = self.cpp_tdm.get_channelgroup_ids() for id in grpids : grpfile = outputdir.decode() + "/channelgroup_" + id.decode() + ".csv" - self.cpp_tdm.print_group(id,grpfile.encode(),True,ord(',')) + self.cpp_tdm.print_group(id,grpfile.encode(),True,ord(','),"".encode()) diff --git a/cython/tdm_reaper.pxd b/cython/tdm_reaper.pxd index 6288235..7ff4352 100644 --- a/cython/tdm_reaper.pxd +++ b/cython/tdm_reaper.pxd @@ -24,5 +24,6 @@ cdef extern from "tdm_reaper.hpp": string get_channelgroup_info(string id) except+ string get_channel_info(string id) except+ # print a channel(-group) - void print_group(string id, const char* filename, bool include_meta, char delimiter) except+ + void print_group(string id, const char* filename, bool include_meta, + char delimiter, string column_header) except+ void print_channel(string id, const char* filename, bool include_meta) except+ diff --git a/lib/tdm_reaper.cpp b/lib/tdm_reaper.cpp index 87ccbee..8078c2d 100644 --- a/lib/tdm_reaper.cpp +++ b/lib/tdm_reaper.cpp @@ -698,7 +698,8 @@ void tdm_reaper::print_channel(std::string &id, const char* filename, bool inclu } } -void tdm_reaper::print_group(std::string &id, const char* filename, bool include_meta, char sep) +void tdm_reaper::print_group(std::string &id, const char* filename, bool include_meta, + char sep, std::string column_header) { // check required path this->check_filename_path(filename); @@ -724,6 +725,7 @@ void tdm_reaper::print_group(std::string &id, const char* filename, bool include int width = 25; + // file header if ( include_meta ) { // group meta data @@ -781,6 +783,30 @@ void tdm_reaper::print_group(std::string &id, const char* filename, bool include allchns.push_back(chndat); } + // provide column header (with channel ids) + if ( column_header.empty() ) + { + for ( std::string chn: chngrp.channels_ ) + { + // use given csv separator token + if ( sep == ' ' ) + { + fou<