Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 17: Importing and Exporting Data


621


Tip
To specify a field containing no data in a delimited file, leave no characters between the commas (not even a
space character). An empty field at the end of a row is indicated by a comma at the end of the line.


Fixed-width text files
Fixed-width text files also place each record on a separate line. However, the fields in each record
are fixed in length. Fields are padded with trailing spaces to maintain spacing within each line, as
shown in Figure 17.13.

FIGURE 17.13

A typical fixed-width text file


Notice that the fields in a fixed-width text file are not separated by delimiters. Instead, they start at
exactly the same position in each record, and each record has exactly the same length.

Text values, such as first and last names, are not surrounded by quotation marks. There is no need
for delimiting text values because each field is a specific width. Anything within a field’s position in
a row is considered data and does not require delimiters.

Note
If the Access table being imported has a primary key field, the text file cannot have any duplicate primary key
values. If duplicate primary keys are found, the import will report an error and fail to import rows with dupli-
cate primary keys.


To import a fixed-width text file, follow these steps:


  1. Open the Chapter17_1.accdb database.

  2. Select the External Data tab.

  3. Click Text File in the Import group.

  4. Find the ImportFixed.txt file using the Browse button, select it, and click OK.


The first screen of the Import Text Wizard (refer to Figure 17.11) appears. The Import
Text Wizard displays the data in the text file and lets you choose between delimited or
fixed-width.

Free download pdf