Converting text file to a database
Article ID: 139 - Updated: Sep 2, 2009 - Products: - Version: Any - Category: License and Activation
Text files are often used as files with data for the labels. Text databse are usually generated from some software that does not have the label-printing features. NiceLabel can use the text file and print the data on the label, thus adding label-printing capability.
The text file is not a real database. This brings two major limitations:
- The text file doesn't have stored the definition of the fields.
The applications can be aware of the field name (if it is stored in the first line in the text file), but not aware of the structure of the text file. The information about fields types (numeric, alphanumeric, etc.) and field lengths is not known and you have to set it manually.
- You cannot define indexes in the text file.
Because of this fact the database connectivity options in NiceLabel software are limited. For example, you cannot change the printing order, or you cannot define a filter on some field.
There is an easy way in NiceLabel software to convert the text file into the real database. The idea is the following: Use NiceData to define the structure of the text file, then use NiceData to save text file into a real database.
Follow these steps:
- Start NiceData.
- Open the text file.
- The structure of the text file is not known so Text File Wizard opens.
- Follow on-screen instructions and define the structure of your text file.
You can store the name of the fields in the first line of the text file.
When you define the structure of the text file, the definition will be save in the file with extension .SCH in the same folder, where the text database is stored. When you open the text file some other time, the structure will be read from the definition .SCH file.
- Create a new empty database in NiceData. Make sure the database has the same structure of fields as the fields in your text file.
- Close the new database in NiceData. Leave the text file opened.
- Select the command Fill from the Tools menu.
- The text file is selected for the 'Source Table'. Select your empty database for the 'Destination Table' field.
- Click on the Map Fields button.
- Link the appropriate fields from the text file and from the database. If the fields have the same names, NiceData will link the automatically.
- Click OK to return to the Fill Table dialog box.
- Click OK to begin with the filling of the table.
Note: the same procedure can be applied automatically. You can use NiceData command-line switches and control the conversion process from some other information. For example, you can define a form in NiceForm where a click on a button will convert text file into real database. Refer to the NiceData help file.