1

I have the following table:

chr [1:1000] "10/16" "1/5" "6/16" "2/5" "7/11" "6/6" "5/5" "2/5" "14/16" "3/5"
"5/5" "7/14" "9/9" "8/9" "7/9" "4/9" "5/5" "1/5" "6/9" "14/16" ...

I want to save this as csv, but when I open csv file the format automatically changes to "date", so I get Oct-2016, 1-May, June-2016 and so on...

How can I export the table "as is"

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Gor
  • 23
  • 6
  • 2
    That's Excel being Excel. You should ask how you can prevent Excel from messing with the format. Possibly you could add `'` in front of all character strings. – Roland Dec 15 '16 at 12:10
  • http://stackoverflow.com/questions/165042/stop-excel-from-automatically-converting-certain-text-values-to-dates – Awais Rafique Dec 15 '16 at 12:32

2 Answers2

0

You write,

when I open the csv file ...

Assuming you are doing this in Excel, understand that the csv file is most likely correct, which you can confirm by opening it in Notepad.

That being the case, one fix is to Import the data by using Data ► Get External Data ► From Text. This will open the Text-to-Columns wizard and you can specify the column containing the values as Text.

enter image description here

Ron Rosenfeld
  • 53,870
  • 7
  • 28
  • 60
  • the problem is that I will export a csv file every day, and need to automatically export as text... – Gor Dec 15 '16 at 12:54
  • @Gor What does exporting have to do with opening the file in Excel? You did not write that you had a problem with exporting the file, only with opening the file. To check if you have exported the file correctly, open it in NotePad and report what you see. – Ron Rosenfeld Dec 15 '16 at 12:56
  • I got the point that it is Excel's problem!!! But as I use only excel in this case, just interesting how can I solve this "problem" – Gor Dec 15 '16 at 13:04
  • @Gor Which problem? Are you having a problem **Exporting**, which is what you keep writing, or not? If you think you are having a problem exporting the csv file, what do you see when you open the file in Notepad? If your problem is only when you **Open the file in Excel**, then what does exporting in CSV every day have to do with the solution I provided? – Ron Rosenfeld Dec 15 '16 at 13:08
0

Just add a "space" or any other character after each item

chr [1:1000] "10/16." "1/5." "6/16." "2/5." "7/11." ...

Here is the code:

Y<-paste0(X," ")
Gor
  • 23
  • 6