4D v13.4Importing data from files |
||||||||||||||
|
4D v13.4
Importing data from files
Importing data from files
You can import data from files in XML, 4D, SYLK, DIFF, DBF, Text, or Fixed Length Text formats (see File formats). If you are importing data that has been exported from another application, see that application’s documentation for information about exporting the data in one of these formats. If the other application uses a different format for exporting data, you may need to modify the file in advance using a text editor or word processor. If you are importing data from another application running on the same platform as your database, first export the data using the other application. Note the order in which the fields were exported, the format the application uses to save the data, and, if the Text format was used, the delimiters used by the application. When importing the data, you must match these settings. You do not need to build your entire table structure before you import data. You can create the required tables directly from the Import dialog box. You have the option of selecting the fields for which data will be imported in the Import dialog box or specifying an input form that contains the fields for which data will be imported. In the Design environment, you import data by the intermediary of the Import dialog box. In the Application environment, you can also display this dialog box (IMPORT DATA command) or directly import files via the commands of the Import and Export theme. To import data in the Design environment:
4D offers you various import options that are accessible through tabs in the import dialog box. The number of tabs as well as their contents vary and depend on the type of file used and the options selected. The options of the “Records” area (File page) specify the main characteristics of the operation:
This page is available only for imports from Text and Fixed Length Text files.
This page allows you to specify the field, record, and file delimiters used in Text and Fixed Length Text files. This options are preconfigured according to the platform specified in the "Destination Platform" menu of Records area. Delimiters are discussed in detail in the Field, record, and file delimiters section. To change the default delimiters, use the drop-down lists containing the values most frequently used for each delimiter. You can also enter a delimiter into the entry areas on the right. Note: The delimiters are reset to their default values if you click the Default button or if the type of the document is modified on the File page. This page is available for XML files only. It allows you to configure the parsing mode of the imported XML contents. At the time of data import, 4D interprets the contents of the XML document in order to extract the information. By default, this operation is carried out without any specific validation. The XML document is assumed to be “well-formed,” meaning that its structure is correct and its interpretation is unambiguous. You can, however, request “validation” of the document at the time of import: to do this, check the Validation option. In this case, 4D parses the contents of the document based on its DTD (Document Type Definition) and checks that it corresponds to this definition. Import is only carried out if the document is validated. Note: For more information on the DTD, refer to XML page. If the DTD of the imported document is not included in the document itself, but is in a separate file, or if you want to use another DTD to validate the document, check the Use alternate DTD option and indicate the file containing the DTD using the [...] button. Once the import is completed, the dialog box is closed and the table into which the data were imported becomes the current table. This page is available for Text, Fixed Length Text and XML files. It allows you to set the formats for imported Boolean fields. The syntax to use is True_Value;False_Value. For example, if you import a column into a Boolean field whose values are “Black” (for true) and “White” (for false), you can enter Black;White. The combo-box displays the most commonly used Boolean formats. You can enter any format that is not in the combo-box. This page appears only for Fixed Length Text files. It allows you to specify the fill characters to use for each data type. The default fill character is the space. For more information about the Fixed Length Text file format, refer to the File formats section. Different fill characters can be used for three data types: Alpha/Boolean (Boolean fields are imported as alphas), Numeric and Date/Time. Normally, the space is used to pad fixed format fields. The drop-down lists contain other choices. The entry areas to the right display the selected fill character. If you wish to use other characters, enter them directly in the entry areas. The menu at the top of the page allows you to view the fill characters in different formats: Character, Decimal (default format), and Hexadecimal. An unprintable fill character will not appear if you use the Character format menu. If you want to import a text file into a form, click the Form tab located at the top of the Table and Field Selection Area. The advantage of using a form is that the form and object methods associated with it are executed as each record is imported. This allows you to process data while importing data (i.e., without writing a custom import routine). You can use forms that contain enterable variables and fields, but not buttons. The form method and the methods associated with variables and fields will be executed when each record is imported. Note, however, that the effects of these methods are not shown in the Preview area. If you use a form for the import, please keep the following considerations in mind:
Note for 4D Server: It is not possible to import data using a form that includes methods in a stored procedure on the server. In fact, since form events are not managed on the server, the associated methods will not be called. |
PROPERTIES
Product: 4D |
||||||||||||