Import Text File
This command lets you import any structured text file into XMLSpy and convert it to XML format immediately. This is useful when you want to import legacy data from older systems. The steps for importing data in a text file as an XML document are described below.
|1.||Select the menu item Convert | Import Text File. The following dialog appears:|
|2.||Select one of the following:|
•Map EDI, CSV, or fixed-width text data into XML (you must have installed Altova MapForce in order to select this option)
•Convert CSV text file into XML
|3.||Click OK. The Text import dialog appears (screenshot below). How to use this dialog is described below.|
Enter the path to the file to import in the Path text box, or select the file using the Browse button to the right of the text box. After the file is selected, a Grid View preview of the XML file is displayed in the Preview pane. Any change in the options selected in this dialog will be reflected in the preview immediately.
To successfully import a text file, you need to specify the field delimiter that is used to separate columns or fields within the file. XMLSpy will auto-detect common row separators (CR, LF, or CR+LF).
Text files exported from legacy systems sometimes enclose textual values in quotes to better distinguish them from numeric values. If this is the case, you can specify what kind of quotes are being used in your file, and remove them automatically when the data is imported.
The data is converted into Unicode (the basis of all XML documents), so you need to specify which character-set the file is currently encoded in. For US or Western European Windows systems this will most likely be Codepage 1252, also referred to as the ANSI encoding.
If you are importing 16-bit or 32-bit Unicode (UCS-2, UTF-16, or UCS-4) files, you can also switch between little-endian and big-endian byte order.
First row contains column names
It is also very common for text files to contain the field names in the first row within the file. If this is the case, check this check box.
In the Preview pane you can rename column headers by clicking in a name and editing it. The column headers will be the element or attribute names in the XML document. You can also select whether a column should be an element or an attribute in the XML document, or whether it should not be imported into the XML document. Click the column-type icon in each column header to toggle through these options. In the screenshot above, Col1 is an element, Col2 is an attribute, and Col3 will not be imported.
When you are satisfied with the options, click Import. The imported data is converted into an XML document that is displayed in Grid View.