//=====
void WriteColumnsString::Process()
{
-
- std::cout << "MLER WriteColumnsString::Process Start " << std::endl;
-
std::ofstream write_fi;
- write_fi.open(bbGetInputFileName().c_str());
- //std::cout<<"write_fi "<<bbGetInputFileName().c_str()<<std::endl;
- std::vector<std::string> headers = bbGetInputHeaders();
-
- int i,j,k;
-
- if(write_fi.is_open())
+ write_fi.open(bbGetInputFileName().c_str());
+ std::vector<std::string> headers = bbGetInputHeaders(); //Headers Input
+ bool onHeaders = bbGetInputOnHeaders();
+ std::vector<std::vector<std::string> > values;
+ values.push_back(bbGetInputlstData1());
+ values.push_back(bbGetInputlstData2());
+ values.push_back(bbGetInputlstData3());
+ values.push_back(bbGetInputlstData4());
+ values.push_back(bbGetInputlstData5());
+ values.push_back(bbGetInputlstData6());
+ values.push_back(bbGetInputlstData7());
+ values.push_back(bbGetInputlstData8());
+ values.push_back(bbGetInputlstData9());
+ std::vector<std::vector<std::string> >::iterator it;
+ for(it = values.begin() ; it != values.end() ; )
{
- for(i=0 ;i< headers.size(); i++ )
+ if((*it).empty())
{
- write_fi << headers[i] << "\t";
- }//for headersSize
-
- for(j=0; j< bbGetInputlstData1().size();j++)
+ it = values.erase(it);
+ }else
{
- write_fi << bbGetInputlstData1()[j] << "\n";
+ it++;
+ }
+ }
+ if(write_fi.is_open())
+ {
+ if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
+ {
+ //Add each header input write to file
+ for(unsigned int i=0 ;i< headers.size(); i++ )
+ {
+ if(i==(headers.size()-1))
+ {
+ write_fi << headers[i] << "\n";
+ }else{
+ write_fi << headers[i] << "\t";
+ }
+
+ }//for headersSize
+ }
+ unsigned int colSize = values[0].size();
+ for(unsigned int j=0;j<colSize;j++)
+ {
+ for(unsigned int i=0;i<values.size();i++)
+ {
+ if(i==(values.size()-1))
+ {
+ write_fi << values[i][j] << "\n";
+ }else{
+ write_fi << values[i][j] << "\t";
+ }
+ }
}
-
- std::cout<<"size Header"<<headers.size()<<std::endl;
-
-
}// if write_fi.is_open()
else
{
std::cout<<"No es posible abrir"<<std::endl;
}//else
-
write_fi.close();
-
- bbSetOutputOutFileName("Prueba.txt");
-
- std::cout << "MLER WriteColumnsString::End Process " << std::endl;
-
+ bbSetOutputOutFileName(bbGetInputFileName().c_str());
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
bbSetInputFileName("");
+ bbSetInputFileName("true");
}
//=====