Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
2  
I am pretty sure the only way is to go through the Import Wizard. The CSV open is a convenience feature to open the file and you are limited by the default behavior. –  Brad Patton May 15 '13 at 18:57
    

1 Answer 1

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.

share|improve this answer
    
That is also the only way I know. Excel is pretty braindead when it comes to CSV handling. You can't even tell it to treat everything in the file as plain text (which should be the default imho if you doubleclick the CSV instead of importing it via the File-Open wizard). –  Tonny May 15 '13 at 18:43
    
How do you do that when opening the file? Or I am missing something... –  Jerry May 15 '13 at 18:49
    
@Jerry Edit the file with a plain text editor like Notepad before loading it into Excel. Yes... I know... You might just as well start Excel first and then open the CSV through File-Open and set the type via the wizard. That's actually less hassle. As I said. Excel is stupid about CSV handling. –  Tonny May 15 '13 at 21:40
    
Ah, okay, that clears the process up :) And yes, even if I were to use a script to add the equal sign... the import wizard would be a much simpler and faster method. –  Jerry May 16 '13 at 6:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.