Aspen Import Tool TEC05 Liz Lucchese Agenda • • • • • Overview Anatomy of an import Using the examples References Tips & tricks for working with text files Overview Underlying technology shared with exports, procedures, and reports • Requires finding the Object Identifier (OID) for the desired table, as well as the OID for each field in that table User input screen XML and/or Java definition Runs in the Job Queue Anatomy of an Import A standard import has just two components: • File to be imported • XML definition Text file to import “100”,“10017”,“Joe” “101”,“23007”,“Jill” “102","58092”,“James” © 2007, All Rights Reserved XML definition <import table-id="tblX"> <direct-field id="y" match="true"/> <direct-field id="z"/> </import> Anatomy of an Import • Update the Student table. • Text file does not include quotes. <import table-id="tblStudent" mode="update" value-wrapper="" force="true"> <direct-fields> <direct-field id="stdIDLocal" match="true" /> <direct-field id="stdFieldA041" /> <direct-field id="stdFieldA042" /> <direct-field id="stdFieldA048" /> </direct-fields> </import> Let’s dissect our first line in our import: <import table-id="tblStudent" mode="update" value-wrapper="" force="true"> • <import • Then let’s choose our table • Tableid=“tblStudent” This field (labeled as the object identifier) can be found in the details of the database table in the Data Dictionary. • mode=“update, insert, or both” • valuedelimeter= • value-wrapper= • force= Anatomy of an Import An import definition allows pre-import criteria to be set: • For importing Ref Table values, you must select the Ref Table. • For importing test scores, you must select the test definition. Import definition <tool-input> <picklist field-id="..." > </tool-input> Text file to import “100”,“10017”,“Joe” “101”,“23007”,“Jill” “102","58092”,“James” XML definition <import table-id="tblX"> <direct-field id="y" match="true"/> <direct-field id="z"/> </import> Example 1 – Reference Code Import Importing new reference codes into a table: <import table-id="tblRefCode" mode="insert” value-wrapper=“”> <preset-fields> <preset-field id="rcdRtbOID" match="true" source="input" value="referenceTableOid" /> </preset-fields> <direct-fields> <direct-field id="rcdCode" match="true" /> <direct-field id="rcdDescription" /> </direct-fields> </import> Import your file! © 2007, All Rights Reserved Example 1 – Reference Code Import Your results should look something like the following: Import Results ============== File: sample-data-reference-codes.csv Records matched: 0 Records updated: 0 Records inserted: 120 Records skipped: 0 ----------------------Total records: 120 © 2007, All Rights Reserved <import table-id="tblStdFee" mode="insert" value-wrapper="" force="true"> <preset-fields> <preset-field id="feeCtxOID" source="input" value="contextOid" /> <preset-field id="feeDate" source="input" value="date" match="true" /> <preset-field id="feeType" source="input" value="type" match="true" /> <preset-field id="feeAmount" source="input" value="amount" match="true" /> </preset-fields> <direct-fields> <direct-field id="relFeeStdOid.stdIDLocal" match="true" /> <skip/> <skip/> <direct-field id="feeFieldB001" /> <skip/> <direct-field id="feeComment" /> </direct-fields> </import> © 2007, All Rights Reserved Inserting Student Fee Records Your results should look something like the following: Import Results ============== File: newfees.txt Records matched: 0 Records updated: 0 Records inserted: 0 Records skipped: 165 ----------------------Total records: 165 Invalid Records =============== Line 1: Could not find a unique match for the related OID Line 2: Could not find a unique match for the related OID Line 3: Could not find a unique match for the related OID Line 4: Could not find a unique match for the related OID © 2007, All Rights Reserved What Happened?! Let’s review our XML Definition for possible errors Example 3 – Student Program Import Importing Student Programs <import table-id="tblStdProgram" mode="insert" value-wrapper=""> <direct-fields> <direct-field id="pgmFieldA001" /> <direct-field id="relPgmStdOid.stdIDState" match="true" /> <direct-field id="pgmProgramCode" /> <direct-field id="pgmFieldA003" /> <direct-field id="pgmFieldA002" /> <direct-field id="pgmFieldB001" /> <direct-field id="pgmActionStart" /> </direct-fields> </import> © 2007, All Rights Reserved References BKF04 – Introduction to XML course materials Import samples with data in the samples folder http://www.w3schools.com/xml/default.asp XML Document Type Definitions (DTDs) in the samples folder: import.dtd filter.dtd tool-input.dtd © 2007, All Rights Reserved Tips & Tricks for working with text files TextPad and Notepad++ both have out-of-the-box syntax coloring for XML files Notepad++ allows XML tag blocks to be expanded and collapsed Both allow "block highlighting" using the ALT key when clicking and dragging This allows you to highlight a column and delete it, much like you would in Excel © 2007, All Rights Reserved Tips & Tricks for working with text files TextPad allows search and replace (Search menu -> Replace, or CTRL+H) to take a text file without quotes and easily add them Replace all instances of a comma with "," Replace all instances of a line feed \n with "\n" using Regular expressions © 2007, All Rights Reserved Thank you! elucchese@x2dev.com