You are not logged in.
Announcement
Unanswered posts
|
Since you've used my code (which you can see works in the image I posted) and you say referencing "tFileList_1_CURRENT_FILE" works after tAggregateRow, the probable reason you're not getting the file name is that you haven't included FileName in the Group By part of tAggregateRow.
PS: Glad to help; it was a far more interesting question than the usual for this forum ![]()
Wow, thanks so much! This is exactly how I was envisioning doing it, but being the Java novice that I am, I couldn't work out the code. One issue I'm having is that the FileName row is always null. I can use a tMap after the tAggregateRow, with (String)globalMap.get("tFileList_1_CURRENT_FILE") in place of FileName, so it's not a huge deal. I'm assuming it's something to do with the Java code I'm using. I've attached the contents of the tJavaFlex component. Again, thanks a lot for this.
Using the following test files, where the first row of each file is assumed to be the header:
test.txt
A|B|C
1||3
|2|3
1|2|3
test2.txt
F|A|X
|A|B
C|D|E
F|G|
the following job does what you want:
- tFileInputFullRow uses (String)globalMap.get("tFileList_1_CURRENT_FILEPATH") for the file name
- row2 schema is FileName and line
- tNormalize normalises the line column separating on "~~"
- tExtractDelimitedFields splits the line column separating on "::"
- row4 schema is FileName, ColName and ColValue
- tReplace searches for whole word "" in ColValue and replaces with null
- tAggregateRow groups on FileName and ColName and outputs count of ColValue ignoring nulls
- tJavaFlex code is as follows:
Start code
-----------------------------------
int RowNum = 0;
String[] ColNames = {""};
int ColNum = 0;
Main code
-----------------------------------
RowNum++;
if (RowNum==1) {
ColNames = row1.line.split("\\|",0);
row2.line = ColNames[0] + "::"; }
else {
ColNum = 0;
row1.line = ColNames[0] + "::" + row1.line;
Integer DelimIndex = row1.line.indexOf('|');
while (DelimIndex>=0) {
ColNum++;
row1.line = row1.line.replaceFirst("\\|", "~~" + ColNames[ColNum] + "::");
DelimIndex = row1.line.indexOf('|'); }
row2.line = row1.line; }
row2.FileName = (String)globalMap.get("tFileList_1_CURRENT_FILE");Just replace tLogRow with tOracleOutput (assuming your table has the ID field set to auto-increment) and voilà.
I have pipe-delimited flat files with a wide variety of unpredictable schemas. I would like to create a table in Oracle that contains an ID, the file name, the column name, and the number of non-null records in that column. There would be a record for each column in each file. I know I could use tAggregateRow and tNormalize to do this with an unchanging schema, but I'd like to be able to use the same job for any pipe-delimited file, regardless of its schema. Any ideas?