You are not logged in.
I also have related issue..
In my job i am reading data from CSV file..and on the basis of first column in every row i create update the GlobalMap, and use map value to set files name..(because i want to create multiple files from CSV)..for do so:
I write this path:
Here "NEtName" is key..
But it create one file named as "null.csv" instead of multiple files with different names and in different directory under "NEM" directory..
My flow is:
i also System.out.println(); to track vaues using tJavaRow here correct values are coming..
Hello rbaldwin and others...
I have a similar task to clems787 in that I need to create multiple CSV files whose name and content depends on a column value from a SQL Server table. There are about 50 different values for this column (ShopId) that will result in about 50 output files. The basic requirement restated: read the input table and write some of the columns out to a file whose name is "Shop" + ShopId + ".csv." There may be multiple rows written out, so I'll be appending to the CSV if it exists.
I've tried to use globalMap and context variables based on other solutions and tutorials, but since I'm not a Java programmer by trade I don't yet "get" what they are and realize that I'm pretty much shooting in the dark.
If you (or anyone) can help teach me, I'd certainly appreciate it!
Thanks in advance for any assistance
The screenshots attached to this post show how to use a tLoop to iterate through list elements. In the tJava_2 component, I initialize a list and then place it into the globalMap. I then configure the tLoop component to iterate through the elements in the list. Finally the tJava_3 component prints the values I pull from the list with a System.out.println().
Hope that helps.
You're right, it's working very well now !
Thanks for your help !
Just one more little thing, your mentioned that i could iterate on a list with tForeach of tLoop.
I don't see how i could pass a dynamic list (stored in the globalMap) in these components.
Can you give me some directions for this ?
Check the tFileOutput component and insure that you're using the row from the tJavaFlex. In the screenshot I posted above, notice how the tFileOutputDelimited has row1.fileName as the variable that it's using - the whole value for the file name is:
"C:/TDQ/3.1.3/TDQ_EE-All-r26090-V3.1.3/workspace/examples/" + row1.fileName + ".txt"
If you're using the row number from the tFixedFlowInput - in my screenshot this is row2, so row2.fileName - it will be one value behind what you're looking for, which would explain the "null","one","two","three" that you're seeing.
Ok, i think we are getting close to what i want but there is still some problems.
I tried your solution, but i dont get "one", "two", "three", "four" created, but "null", "one", "two", "three" ....
Any idea ?
In order to do what you're trying to do, you'll need to use a tFlowToIterate. I've attached screenshots that show how to do this. One shows the whole job, then each of the major components settings are shown, and the results of the job's execution is shown. The tFlowToIterate component is the important one, because it will change how the job attempts to create the file - without it, it's at flow initialization time, which is before your tJavaFlex's start block is executed. The tFixedFlowInput is simply there to pull the flow back into a row that goes to the tFileOutputDelimited. In addition to the tJavaFlex to tFlowToIterate, you could also, presumably use a tForeach to loop through your list or a tLoop component.
Hope that helps.
Here is a screenshot of the part of my job causing the problem.
The choice of my components might not be the good one ...
Can you upload a screenshot of your job and show us more info about your job? You put the 'for' in the start code part of tJavaFlex, and this part code will be only executed one time.
I'm current working on a job that has to write in different files. The number of files is defined at runtime, as well as the name of each file.
I have access to the list of all files in an entry of the globalMap.
My first thought was to iterate on this list in a tJavaFlex component, store the current filename in the globalMap, and use this globalMap entry in the tFileOutputXX filename field.
The problem is that this filename value is setup only once, at initialization of the subjob, and not for each row going out of the tJavaFlex.
As a result, all my rows goes to a "null.txt" file ...
I'm waiting for your ideas to solve this problem !