Home > Software design >  View CSV file date as raw string in Excel
View CSV file date as raw string in Excel

Time:03-07

I have a CSV file which has time column and its values are String in dd MMM HH:mm format.

Name,Time
Farms,20 Dec 14:00

When I open the CSV file with Excel, Excel automatically converts these Timevalues to date format, thereby modifying to add year value on its own. So 20 Dec 14:00 is converted to 20/12/22 14:00.

What I want is that Excel should display the time column values as raw string, i,e. 20 Dec 14:00.

Some similar questions, suggetsed to modify the CSV file by adding = symbol before the time column values, so that excel treat it as string. But this is not what I want. I don't want to make any changes to CSV file, but want a way by making some changes in Excel itself.

CodePudding user response:

Instead of opening the .CSV file by directly double-clicking, or dragging it onto an EXCEL instance, try using File->Open method, and use the text import Wizard, choose the comma delimiter, and when when it asks for the type of the column, choose text (you can choose multiple columns and choose text).

Alternatively, create a new empty worksheet, format the first column as text, open the file in a good text editor (like Notepad ), copy whole text (Ctrl-A, Ctrl-C), Alt-tab to EXCEL, place the cursor in A1, and paste (Ctrl-V). Now you can use the Data->Text to Columns wizard, and again you can choose text as type.

It can also be done in VBA, but performing the above steps are acceptable then why.

  • Related