Excel – Any way to have Excel 2010 treat a quoted value “08540” as text not number when opening a CSV

csvmicrosoft excelmicrosoft-excel-2010

I have a CSV with data like this:

  "08540",1,"PRINCETON","NJ"

I know that it is possible to specify "Text" when using the Import Wizard and defining columns. But is there a way to tell Excel to treat quoted values as Text when Excel opens a CSV file?

Best Answer

There is no way to do it automatically. You need to convert the file to the following format first:

="08540",1,"PRINCETON","NJ"

If your files do have the format as you said (i.e. all you need is to add = in the beginning of every line) then the conversion is easy. Create a CONVERT.BAT file on your Desktop with the following code:

@echo off
mkdir "%USERPROFILE%\Desktop\Converted CSV files"
:next
if '%1'=='' goto done
set CSV="%USERPROFILE%\Desktop\Converted CSV files\%~nx1"
for /F "tokens=*" %%A in ('TYPE %1') do echo =%%A >>%CSV%
shift
goto next
:done

Now you can drag-n-drop your .CSV files on the CONVERT icon. The processed files will appear in the Converted CSV files folder.

Related Question