0

I'm working on a script that outputs data to .CSV format, but when these files are loaded into Excel, Excel will often re-format the data a specific way.

For example

"0115","5.5%","2008-01-01"

might be read into Excel and displayed by default as:

"115"  "5.50%"   and "01/01/08"

Is there any way, within the format of a CSV to tell Excel to leave the data as-is and not interpret it as a specific data type? Actually I would like the ability to have Excel recognize certain numeric fields and right justify them, but not necessarily add decimals or change the date display format. Any alternatives?

marked as duplicate by Scott, music2myear, bertieb, Pimp Juice IT, phuclv Jul 31 '18 at 11:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What code is in your script? This should be possible by parsing the data as a string, but this removes a lot of functionality. You might be able to specify the format for each cell, im not an expert on this but adding your script would help. – Kevin Anthony Oppegaard Rose Jul 20 '18 at 16:56
  • yes tell excel to read the data as string in the import. – Rob Jul 20 '18 at 16:56
  • Another option is to allow excel to interpret the data correctly and change the format of the cells so it matches the format you want. Not sure if it is possible for all data types. – Rob Jul 20 '18 at 16:57
  • It seems as though you have accidentally created two accounts, you can merge your accounts here. – bertieb Jul 20 '18 at 17:01
  • 1
    In general, .csv files should be imported and not opened. If you do this, you will be able to specify the column format at the time of import. There's no good way of including desired format in a .csv file, although you might try to precede text fields with the single quote mark '. This will show in the formula bar, but won't show in the worksheet cell and it tells Excel to treat the entry as text. – Ron Rosenfeld Jul 20 '18 at 19:15

Browse other questions tagged or ask your own question.