FAQ's - APPX Software, Inc. : APPX Utility : APPX Development Environment : Tips & Techniques :
How can I import consecutive (flat) files into APPX? | |
APPX users often find the need to import data from external sources into APPX. What methods can be used to bring consecutive (flat) data files into the APPX database files?
| |
Here are three approaches:
1. If the file is "columnar" (all the data lines up into columns, and all the records have the same fixed length), define an APPX Data Dictionary file and fields corresponding to the columns for the fields, and read it directly. Have a 2-byte alpha field at the end, the 'absorb' the hex(0d0a) that Windows apps usually put on the end of each of the line, to denote end of line. See "to import a flat file" below. 2. Create an APPX consecutive file with a single 1-byte alpha field. Use it to read the text file into APPX, one byte at a time. Build a record buffer, testing for hex(0d0a) to determine the end of each record, and then writing it out to the file. 3. Using the ",RT_" commands to read the file. 'RT' commands are unsupported and subject to modification, but are often used for these sorts of tasks. We use them in the UPDATE process generated by our "Comma Delimited Update" process within Utilities/Toolbox. You might look at an UPDATE generated by this utility, to get a feel for how the commands work. To import Tab delimited variable length files into APPX, check this document from "Sparky and Spike" at CANSYS West: http://www.cansyswest.com/importin.htm
-------------------------------------------------------------------------------- 1. Export the file from Excel into a fixed length format. 2. Define a Consecutive file in APPX, with all Alpha fields, matching the column widths of each Excel column, as exported. 3. Add a 2 byte alpha at the end of the APPX DD, to receive the hex(0d0a) that Excel and other Windows applications append to records to denote record boundaries. 4. Design Transfer the design for the Consecutive file defined above into a 2nd APPX file. 5. Change the field types you want to be other than Alpha, into their other field type. (Numeric, Date, or whatever.) Add indices. 6. Run 'Create Files' on both the Consecutive and Indexed files. 7. FTP the file to your Unix box in ASCII format. 8. Move the FTP'd file into your Data directory as the name of the Consecutive f ile. (Filename is all upper case, with a lower case .dat suffix.) 9. Write an OUTPUT that reads the Consecutive file and reports on its contents. Within the 'Select Image' event point, write ILF that moves field contents from the Consecutive file into the Indexed file. Write the new record. If you try to write two records with the same Primary or Unique Key, the WRITE will fail. Check the False condition on a WRITE to catch that and handle it accordingly. Set --- ALTERNATE IMAGE NUMBER in Select Image to selectively display/print records of interest. Date fields will require special manipulation. Use SET TEMP commands, to get them into APPX date format.
Run the above OUTPUT on this FTP'd file, converting it from Consecutive into Indexed format. Examine the resulting files. Modify your OUTPUT as needed.
| |
[Append to This Answer] | |
2003-Nov-18 3:07pm |
Previous: | How do I send a file to a client PC and open the file with a client side App? (i.e. Excel) |
Next: | Checking return code after a Stream Write. |
|