Hi,
I am reading multiple files from a location (*.txt). I want to get the name of the file to enter into database. I tried using auto_filling to capture the source_name but it fails.
Can you please let me know how to capture the filename?
Thanks
Nag
Attached code below:
<?xml version="1.0" encoding="UTF-8"?>
<Graph author="scndmouse" created="Wed Feb 18 19:55:05 GMT-05:00 2009" guiVersion="2.1.3" id="1235006073559" licenseType="Evaluation license." modified="Tue Apr 14 10:49:48 PDT 2009" modifiedBy="naga" name="test2" revision="1.130">
<Global>
<Metadata id="Metadata4" previewAttachment="C:/eclipse_workspace/testinsert/data-in/data1${PROJECT}txt" previewAttachmentCharset="ISO-8859-1">
<Record fieldDelimiter="," name="recordName5" previewAttachmentCharset="ISO-8859-1" recordDelimiter="\r\n" skipFirstLine="false" type="delimited">
<Field name="First_Name" size="50" type="string"/>
<Field name="Last_Name" size="50" type="string"/>
<Field delimiter="\n" name="Salary" size="10" type="number"/>
<Field auto_filling="source_name" delimiter="\r\n" eofAsDelimiter="true" name="filename" size="100" type="string"/>
</Record>
</Metadata>
<Connection dbConfig="conn/testconnection.cfg" id="Connection0" type="JDBC"/>
<Property fileURL="workspace.prm" id="GraphParameter0"/>
</Global>
<Phase number="0">
<Node dataPolicy="controlled" enabled="enabled" fileURL="${DATAIN_DIR}/*.txt" guiHeight="0" guiName="UniversalDataReader" guiWidth="0" guiX="111" guiY="99" id="DATA_READER0" skipRows="0" type="DATA_READER"/>
<Edge fromNode="DATA_READER0:0" guiBendpoints="" id="Edge1" inPort="Port 0 (in)" metadata="Metadata4" outPort="Port 0 (output)" toNode="DB_OUTPUT_TABLE0:0"/>
</Phase>
<Phase number="1">
<Node cloverFields="Salary;First_Name;Last_Name" dbConnection="Connection0" dbTable="CLOVERETL" enabled="enabled" fieldMap="$First_Name:=FIRST_NAME;$Last_Name:=LAST_NAME;$Salary:=SALARY;" guiHeight="0" guiName="Write into db" guiWidth="0" guiX="594" guiY="113" id="DB_OUTPUT_TABLE0" passThroughOutputPort="1" type="DB_OUTPUT_TABLE"/>
</Phase>
</Graph>
I am reading multiple files from a location (*.txt). I want to get the name of the file to enter into database. I tried using auto_filling to capture the source_name but it fails.
Can you please let me know how to capture the filename?
Thanks
Nag
Attached code below:
<?xml version="1.0" encoding="UTF-8"?>
<Graph author="scndmouse" created="Wed Feb 18 19:55:05 GMT-05:00 2009" guiVersion="2.1.3" id="1235006073559" licenseType="Evaluation license." modified="Tue Apr 14 10:49:48 PDT 2009" modifiedBy="naga" name="test2" revision="1.130">
<Global>
<Metadata id="Metadata4" previewAttachment="C:/eclipse_workspace/testinsert/data-in/data1${PROJECT}txt" previewAttachmentCharset="ISO-8859-1">
<Record fieldDelimiter="," name="recordName5" previewAttachmentCharset="ISO-8859-1" recordDelimiter="\r\n" skipFirstLine="false" type="delimited">
<Field name="First_Name" size="50" type="string"/>
<Field name="Last_Name" size="50" type="string"/>
<Field delimiter="\n" name="Salary" size="10" type="number"/>
<Field auto_filling="source_name" delimiter="\r\n" eofAsDelimiter="true" name="filename" size="100" type="string"/>
</Record>
</Metadata>
<Connection dbConfig="conn/testconnection.cfg" id="Connection0" type="JDBC"/>
<Property fileURL="workspace.prm" id="GraphParameter0"/>
</Global>
<Phase number="0">
<Node dataPolicy="controlled" enabled="enabled" fileURL="${DATAIN_DIR}/*.txt" guiHeight="0" guiName="UniversalDataReader" guiWidth="0" guiX="111" guiY="99" id="DATA_READER0" skipRows="0" type="DATA_READER"/>
<Edge fromNode="DATA_READER0:0" guiBendpoints="" id="Edge1" inPort="Port 0 (in)" metadata="Metadata4" outPort="Port 0 (output)" toNode="DB_OUTPUT_TABLE0:0"/>
</Phase>
<Phase number="1">
<Node cloverFields="Salary;First_Name;Last_Name" dbConnection="Connection0" dbTable="CLOVERETL" enabled="enabled" fieldMap="$First_Name:=FIRST_NAME;$Last_Name:=LAST_NAME;$Salary:=SALARY;" guiHeight="0" guiName="Write into db" guiWidth="0" guiX="594" guiY="113" id="DB_OUTPUT_TABLE0" passThroughOutputPort="1" type="DB_OUTPUT_TABLE"/>
</Phase>
</Graph>
-
Hello,
you have duplicated delimiter after the last field. Your metadata should look like follows:<Metadata id="Metadata4" previewAttachment="C:/eclipse_workspace/testinsert/data-in/data1${PROJECT}txt" previewAttachmentCharset="ISO-8859-1">
<Record fieldDelimiter="," name="recordName5" previewAttachmentCharset="ISO-8859-1" skipFirstLine="false" type="delimited">
<Field name="First_Name" size="50" type="string"/>
<Field name="Last_Name" size="50" type="string"/>
<Field delimiter="\n" name="Salary" size="10" type="number"/>
<Field auto_filling="source_name" delimiter="\r\n" eofAsDelimiter="true" name="filename" size="100" type="string"/>
</Record>
</Metadata> -
Thanks for the reply.
I got rid of the duplicate metadata. It still did not work. I get red color on the salary field and all the values go blank.
When I moved the position of the new field (source_field, up and down in metadata editor), it started working.
Thanks
Nag
Please sign in to leave a comment.
Comments 2