How to Import Data Into Your Model
Look for the Upload Files icon in the toolbar. Click on the icon to display the import wizard. The datalist name is initialized to "Datalist1". You may change the name to something more appropriate for your data. Then click on the Next button.
Specifying Your Data Source
On the second page of the import wizard click on the folder icon next to the source file input to display the file selection dialog. Select the file you wish to import, and click on the Open button. The wizard will automatically detect the type of file selected and display the applicable settings. In this case, the input is a text file filled with comma separated values (CSV). The settings enable you to configure whether the values are delimited by a special character, or occupy fixed length fields. You may change the delimiter or the quote character. You may specify whether or not the data has column headers, in what row the headers begin, and how many rows have column headers. You may also specify whether or not the data includes a footer, and how many rows contain the footer. The wizard will do its best to utilize the column headers provided in the input file, and will omit the footer, if specified.
Click on the Next button to proceed.
Summary and Finish
The wizard displays a summary of your selections on the third page. Click the Finish button to complete the process and import your data. The wizard will display a summary of files imported, or error messages, if there was a problem. Click on the Finish button to close the wizard. At this point, the newly created datalist appears in the tree view. Click on the datalist name to display the data you imported.
Importing Data From Excel Files
When importing data from excel files, the datalist name that you enter on the first page of the wizard takes on new meaning. That will become the prefix for all of the datalist names, as you will see later in this tutorial. After entering the desired prefix, click on the Next button. Select the workbook file using the file selection dialog on the second page of the import wizard. The settings for excel files will appear below the file name. The first setting displayed under Excel file properties is a combo box that provides a list of all the worksheets, named ranges, and tables defined in the selected workbook. Use the check boxes in the drop down list to indicate what portions of the workbook you would like to import. Initially, the wizard selects the the first worksheet. The formula handler setting determines how the wizard will process formulas.
Formula Handler Options
|Omit Formulas||Ignore formulas. Treat cells with formulas as if they were empty.|
|Copy Values||Try to evaluate each formula in each cell, and copy the resulting value into modelshop.|
|Copy Formulas||Copy the formulas without evaluating them. The wizard will attempt to interpret simple formulas and insert the equivalent groovy expression in the datalist. If the wizard is unable to interpret a formula, then it will insert the formula as a comment in the datalist.|
Here also there are settings for whether or not there are header and footer rows, how many of each, and what is the first header row. The same settings will apply to each of the selected components from the worksheet. In the example shown above, the Sales Detail worksheet and the Expenses worksheet both have column headers in the first row, and one row of summary data that is to be omitted. Click on the Next button to view the import summary, and then the Finish button to complete the process. Notice that in the tree view, there are now three datalists. The wizard created two datalists corresponding with the two spreadsheets from the workbook. Their names consist of the datalist name, "Retail", provided to the wizard, followed by the names taken from the respective worksheets. If you find that after importing the data it is not quite what you expected, then you may need to use the connector editor to refine connector's configuration.
Importing Data From XML Files
Enter the datalist name on the first page of the wizard, and click on the Next button. On the second page, click on the folder icon next to the Source File input. Use the file selection dialog to find and select the XML file. The settings for XML files will appear below the file name. You must enter a data class name and jaxb context. In this example, the data consists of credit reports from the Experian service. The data class name and jaxb context direct the wizard to the schemas that define the structure of the XML content. Click on the Next button to view the import summary, and then the Finish button to complete the process. Click on the finish button to close the wizard. Click on the datalist in the tree view to see the imported data. In this case, the data consists of a single field containing a series of XML data objects. To extract and display data elements from these objects, you will have to define additional fields manually using the datalist editor. These fields will have expressions that reference elements of the XML objects.