Page 1 of 1

Generate multiple output files for a single output stage

Posted: Thu Nov 15, 2007 11:53 pm
by tech_savvy
Hi All,

Issue: There is a single column(name) table with ten records, requirement is to provide seperate output file for each record.. with column value as the file name.

name: (1, 2, 3, 4, 5) as values the output must be 1.txt, 2.txt, 3.txt, 4.txt 5.txt

How to achieve this...in a single run :? [/list]

Posted: Fri Nov 16, 2007 12:43 am
by ray.wurlod
Job sequence.
User variables activity to convert the list to delimited list.
Start Loop activity using user variable to control list.
It's been explained before. Search.

Posted: Sun Nov 18, 2007 8:08 pm
by JoshGeorge
A parallel (C++) routine which creates files dynamically will be the best way to do this 'in a single run'.

Posted: Sun Nov 18, 2007 8:28 pm
by JoshGeorge
pxCreateFile: Parallel routine (C++) which creates files dynamically.

Code: Select all

//Creates and writes on a text file for each record
//Pass the FileName with path as first parameter Ex: <Path>: LinkName.InputColumn : '.txt'
//Pass the Content of the file as second parameter Ex: LinkName.InputColumn
//Px routine call --> pxCreateFile(<Path>: LinkName.InputColumn : '.txt', LinkName.InputColumn)
//If file creation is success 0 is returned, else 1. Use this status for report/tracking/print to file/print to peek
//If file already exists, overwrite happens
//Pass '' (empty) as second Parameter if you don't want anything to be printed in the file)


#include <iostream>
#include <fstream>
using namespace std;

int pxCreateFile(char *FileName, char *Msg)
 {
  int StatusFlag=0;
  ofstream myfile (FileName);
  if (myfile.is_open())
  {
    myfile << Msg;
    myfile << "\n"; //Comment this line if a new line char is not required at the end of the file by default
    myfile.close();
  }
  else 
   {
    StatusFlag = 1;
   }

   return StatusFlag;
}