home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD1.img
/
d1xx
/
d103
/
mff-update
/
utilities
/
mffimport.doc
< prev
next >
Wrap
Text File
|
1987-10-25
|
8KB
|
196 lines
The Microfiche Filer Text Import Utility
This utility is (c) Copyright 1987 by Software Visions, Inc. but is freely
distributable. Please feel free to pass it on to your friends who have
bought the Microfiche Filer.
This utility was written because the number one wish of Microfiche Filer
owners was to be able to import text from other databases into the
Microfiche Filer. The Microfiche Filer already has the capability of
exporting text through the "Print To File" option. In fact, using "Print
To File" then using the Text Import Utility you may now even export and
import data between several Microfiche Filer databases!
This program currently does not have a pile of fancy features, it just
does it's job simply and efficiently. It is intended for importing
simple, fixed record size ASCII files of the type that essentially all
databases can create and, in fact, can even be easily created by hand
using a simple text editor. It does NOT read other database's internal
formats but uses absolutely standard ASCII text files. It DOES, however,
know intrinsically about the Microfiche Filer internal file format and,
using this knowledge, allows you to reference fields that you have created
directly, without a bizare command language. If you are comfortable using
the Microfiche Filer, you will have absolutely no problem using the MFF
Text Import Utility (hereafter referred to as the TIU).
What you need to perform a text import:
You may only import into a previously existing database which has been
created using the Microfiche Filer. You will need a COPY of this database.
DO NOT USE YOUR ORIGINAL! The TIU will append data to this database, and,
if you realize that for some reason the data was not formatted correctly,
you don't want to sift through your MFF file with an editor, chopping it
up by hand, do you? You can simply start again by copying your original.
In fact, if you have enough memory, you should probably put the COPY that
you are going to work with in the RAM: disk. This will save a lot of time.
The second thing that you need is a text file to import. It must be set
up with a fixed number of lines per record, and, if it has many fields per
line, they must be in a fixed format. In other words, the file may contain
one field per line with a fixed number of lines per record such as:
Rec 1 Field 1
Rec 1 Field 2 here
Rec 1 Field 3
Rec 2 Field 1 is on this line
Rec 2 Field 2 (notice that the lines may vary in length)
Rec 2 Field 3 (but the number of lines per record must be the same)
Rec 3 Field 1
etc.
Or, the file may contain several fields per line in a fixed format (but
the number of lines per record must still be fixed) such as:
Rec1 Field4 Rec1 Field2 Rec1 Field3
Rec1 Field1 is on this variable line
Rec2 Field4 still ok Rec2 F2 Rec2 F3 and the last one may go on and on
Rec2 Field1
Rec3 F4 Rec3 F2 Rec3 F3
Rec3 Field1 again, (remember this line is variable!)
etc.
Notice that the last field on a line may be variable length, if you like.
When these records are read, the trailing spaces are eliminated; therefore,
the line:
Rec2 Field4 still ok Rec2 F2 Rec2 F3 and the last one may go on and on
would be translated into:
"Rec2 Field4 still ok"
"Rec2 F2"
"Rec2 F3 and the last one may go on and on"
when stored in fields in the database.
Also, note that double quotes ("), and back quotes (`) are translated into
single quotes (') because double and back quotes are special characters to
the Microfiche Filer. In addition, single lines are limited to about 2000
characters. Lines longer than this are partially discarded.
The third thing that you need to perform a text import is a description
of what fields are where in the text file. You may wish to print out a
bit of your text file so that you can determine what columns the fields
begin and end in, or you may simply wish to 'type' them in a cli window
or read them into your favorite editor to determine these starting and
ending character positions. This is only necessary if your text file has
multiple fields per line. If each field is on it's own line, you must
simply know the corresponding line numbers.
Performing a text import:
Start the TIU by double-clicking the icon in the Utilities drawer or by
typing ":mff-update/utilities/mffimport" from the CLI.
NOTE: THE MFF IMPORT UTILITY REQUIRES A MINIMUM STACK SIZE
OF 8000 SO TYPE "STACK 8000" BEFORE RUNNING MFFIMPORT FROM
A CLI.
You are prompted for a database to use.
Give it the name of your COPY!
The TIU then opens a large window, similar to the familiar "Selection Editor"
in the Microfiche Filer. This window is organized somewhat differently,
however. On the left are the names of the input and output files. Since
you have only given it an output file so far, the input filename is blank.
Next, on the left, is a place for you to specify blank lines at the end
of a record in your text file, if any (for instance, if you have 6 lines
of text for each record in your text file but only wish to import the
first and fourth lines, you would put a 2 in this field so that the last
two lines are skipped). And finally, on the right is a scrollable area
listing all of the fields in your database with spaces for you to fill in.
Select "Open Input File" from the FILE menu and enter the name of your
text file.
If the file is found, the name is displayed under "Input file:" in the
window.
Now fill in the "From line", "From char", and "To char" spaces in the
field list corresponding to the positions of these fields in your text
file.
Only those fields in which you enter the "From line" (the line number) will
be used during the import. The other fields will be left blank. This is
all that you need to do if your file consists of records with one field
per line. If you have several fields on a line, you must also fill in the
"From char" and "To char" spaces. Counting starts at 1. The first
character on a line is number 1, etc.
If you leave the "From char" field blank, it will automatically be set to
1. If you leave the "To char" blank, it will automatically be set to 32767.
For instance, the definition for importing the following file:
Rec1 Field4 Rec1 Field2 Rec1 Field3
Rec1 Field1 is on this variable line
Rec2 Field4 still ok Rec2 F2 Rec2 F3 and the last one may go on and on
Rec2 Field1
Rec3 F4 Rec3 F2 Rec3 F3
Rec3 Field1 again, (remember this line is variable!)
etc.
is:
From From To
Field Line Char Char
----------------------
Field1 2
Field2 1 24 36
Field3 1 37
Field4 1 23
In other words:
Field1 is on line 2 from char 1 to 32767;
Field2 is on line 1 from char 24 to 36;
Field3 is on line 1 from char 37 to 32767;
Field4 is on line 1 from char 1 to 23.
Whew. This is much harder to explain than to do!
Don't worry about lines that are too short; the TIU simply blanks the field.
The TIU is also pretty smart about problems with your definition. It will
notify you if you have declared overlapping fields, negative numbers, etc.
Once all of this is done, simply choose "Perform the Text Import" from
the FILE menu and away it goes.
When it is done, your original output file (your database) will have the
fields from your text file appended to it. None of the other data in the
database has been touched.
Importing more complex record formats:
Included in this directory is a program called convert.c. This was just
a quick hack that we whipped up to translate an ASCII file into MFF file
format. You may wish to use part of this code to write your own import
programs to import more complex formats with variable field sizes, comma
separated lists, and so on that the MFF Text Import Utility cannot handle.
Feel free to call our Telephone Support Line for help writing your own
import utilities.
Enjoy!
Software Visions