Re: [R] retaining characters in a csv file

2015-09-23 Thread Daniel Nordlund
On 9/23/2015 5:57 AM, Therneau, Terry M., Ph.D. wrote: Thanks for all for the comments, I hadn't intended to start a war. My summary: 1. Most important: I wasn't missing something obvious. This is always my first suspicion when I submit something to R-help, and it's true more often than not

Re: [R] retaining characters in a csv file

2015-09-23 Thread John Kane
> -Original Message- > From: r.tur...@auckland.ac.nz > Sent: Wed, 23 Sep 2015 13:26:58 +1200 > To: pda...@gmail.com .. > I would say that this phenomenon ("Excel does it") is *overwhelming* > evidence that it is bad practice!!! :-) Fortune? _

Re: [R] retaining characters in a csv file

2015-09-23 Thread Therneau, Terry M., Ph.D.
Thanks for all for the comments, I hadn't intended to start a war. My summary: 1. Most important: I wasn't missing something obvious. This is always my first suspicion when I submit something to R-help, and it's true more often than not. 2. Obviously (at least it is now), the CSV standard

Re: [R] retaining characters in a csv file

2015-09-22 Thread Rolf Turner
On 23/09/15 11:19, peter dalgaard wrote: On 23 Sep 2015, at 00:33 , Rolf Turner wrote: [read.csv() doesn't distinguish "123.4" from 123.4] IMHO this is a bug in read.csv(). Dunno about that: pd$ cat ~/tmp/junk.csv "1";1 2;"2" pd$ open !$ open ~/tmp/junk.csv And lo and behold, Excel o

Re: [R] retaining characters in a csv file

2015-09-22 Thread Rolf Turner
On 23/09/15 12:48, Duncan Murdoch wrote: On 22/09/2015 6:33 PM, Rolf Turner wrote: IMHO this is a bug in read.csv(). No, it's a bug in "Rolf Turner", who believes in fairies at the end of his garden, rather than in documentation for file formats. Naturally, I beg to differ. The docume

Re: [R] retaining characters in a csv file

2015-09-22 Thread Duncan Murdoch
On 22/09/2015 6:33 PM, Rolf Turner wrote: > On 23/09/15 10:00, Therneau, Terry M., Ph.D. wrote: >> I have a csv file from an automatic process (so this will happen >> thousands of times), for which the first row is a vector of variable >> names and the second row often starts something like this: >

Re: [R] retaining characters in a csv file

2015-09-22 Thread Duncan Murdoch
On 22/09/2015 7:19 PM, peter dalgaard wrote: > >> On 23 Sep 2015, at 00:33 , Rolf Turner wrote: >> > > [read.csv() doesn't distinguish "123.4" from 123.4] > >> IMHO this is a bug in read.csv(). >> > > Dunno about that: > > pd$ cat ~/tmp/junk.csv > "1";1 > 2;"2" > pd$ open !$ > open ~/tmp/jun

Re: [R] retaining characters in a csv file

2015-09-22 Thread Duncan Murdoch
On 22/09/2015 6:00 PM, Therneau, Terry M., Ph.D. wrote: > I have a csv file from an automatic process (so this will happen thousands of > times), for > which the first row is a vector of variable names and the second row often > starts > something like this: > > 5724550,"000202075214",2005.02.

Re: [R] retaining characters in a csv file

2015-09-22 Thread peter dalgaard
> On 23 Sep 2015, at 00:33 , Rolf Turner wrote: > [read.csv() doesn't distinguish "123.4" from 123.4] > IMHO this is a bug in read.csv(). > Dunno about that: pd$ cat ~/tmp/junk.csv "1";1 2;"2" pd$ open !$ open ~/tmp/junk.csv And lo and behold, Excel opens with 1 1 2 2 and all cells num

Re: [R] retaining characters in a csv file

2015-09-22 Thread Arunkumar Srinivasan
data.table's fread reads this as expected. Quoted strings aren't coerced. sapply(fread('5724550,"000202075214",2005.02.17,2005.02.17,"F"\n'), class) # V1 V2 V3 V4 V5 # "integer" "character" "character" "character" "character" Best, Arun. On Wed, Sep

Re: [R] retaining characters in a csv file

2015-09-22 Thread David Winsemius
On Sep 22, 2015, at 3:00 PM, Therneau, Terry M., Ph.D. wrote: > I have a csv file from an automatic process (so this will happen thousands of > times), for which the first row is a vector of variable names and the second > row often starts something like this: > > 5724550,"000202075214",2005.0

Re: [R] retaining characters in a csv file

2015-09-22 Thread Rolf Turner
On 23/09/15 10:00, Therneau, Terry M., Ph.D. wrote: I have a csv file from an automatic process (so this will happen thousands of times), for which the first row is a vector of variable names and the second row often starts something like this: 5724550,"000202075214",2005.02.17,2005.02.17,"F", .

Re: [R] retaining characters in a csv file

2015-09-22 Thread Hadley Wickham
The problem is that quotes in csv files are commonly held to me meaningless (i.e. they don't automatically force components to be strings). Earlier this morning I committed a fix to readr so that numbers starting with a sequence of zeros are read as character strings. You may want to try out the d