Importing Data from Delimited Text Files

Problem

You want to import data from a text file, but the data isn't in fixed-width format as in Recipe 3.1. This time, the data is delimited, i.e., separated by commas, spaces, tabs, or some other character.

Solution

Follow the import procedure described in Recipe 3.1, but select Delimited instead of "Fixed width" in step 1 of the Text Import Wizard (see Figure 3-2).

Discussion

When you select Delimited instead of "Fixed width," you don't specify column breaks during step 2 of the import procedure. Instead, you specify the delimiter that separates the data on each row being imported. In this case, step 2 of the Text Import Wizard looks like Figure 3-6 instead of Figure 3-3.

Figure 3-6. Text Import Wizard: Step 2 (Delimited file type)

The example data shown in the data preview window in Figure 3-6 was taken from one of my fluid dynamics simulations. It shows fluid field variables (velocity, pressure, density) as functions of position on a 2D grid. The output file consists of rows of data, with each number separated by a comma. I checked the comma delimiter in the import wizard dialog and the wizard automatically set the column break points. Pressing Next at this point takes you to step 3, as already discussed in Recipe 3.1.

See Also

See Recipe 3.1, Recipe 3.3, and Recipe 3.4 for alternative data importing techniques.

Категории