Marc has a user at his company who is trying to open a .CSV file in Excel. Some of the numbers in the file are in the format of “2-1” (or something similar). During the import, Excel parses this information as a date. If the piece of data is clearly something outside a valid date range (such as 2-134), then Excel imports it as would be expected. Marc is wondering how his user can force Excel to not parse this data as dates but to import them as text fields.
There at two easy ways you can approach this issue. First is to import the file in the following manner:
- Display the Data tab of the ribbon.
- Click From Text in the Get External Data group. Excel displays a standard Open dialog box.
- Use the controls in the dialog box to select the .CSV file you would like to open and then click Open. Excel starts up the Text Import Wizard. (See Figure 1.)
- Go through the steps of the Text Import Wizard to specify how Excel should interpret the data that it imports from the .CSV file. In one of those steps you can indicate that the non-date columns (the ones incorrectly interpreted as dates) are actually text.
- When you are done with the steps of the wizard, click Finish. Your data is imported in accordance with your specifications.
Figure 1. The Text Import Wizard.
The other way to approach the issue also involves the Text Import Wizard, but how you display it is different. In this approach, you use Windows to rename the file so that it has a .TXT extension instead of a .CSV extension. Now, when you use Excel to open the file, it displays the Text Import Wizard because it isn’t quite sure how to interpret what it is going to be loading. You can use the Text Import Wizard in the same manner as already described earlier in this tip.