<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body ><div>Matt</div><div><br></div><div>Thanks for making the change. When will the update be available? </div><div><br></div><div><br></div><div><div style="font-size:9px;color:#575757">Sent from my Verizon Wireless 4G LTE Smartphone</div></div><br><br><div>-------- Original message --------</div><div>From: Matt Dowle <mdowle@mdowle.plus.com> </div><div>Date:01/22/2014 14:40 (GMT-05:00) </div><div>To: jholtman <jholtman@gmail.com>,datatable-help@lists.r-forge.r-project.org </div><div>Subject: Re: [datatable-help] leading spaces on column names from CSV file </div><div><br></div>Hi Jim,<br>Ok yes good idea. The roots of that are due to data.table allows <br>leading and trailing spaces (and all special characters) in column <br>names. The confusion that by="a, b, c" doesn't work due to the spaces, <br>due to column name " b" being different to "b". But for fread that <br>doesn't make sense and it should drop the leading spaces by default, <br>yes. I've added this to the top of fread.c where I'm logging the fread <br>ToDos.<br>Thanks, Matt<br><br><br>On 22/01/14 16:21, jholtman wrote:<br>> I have a CSV file that I had been reading with 'read.csv' and it turns out<br>> that the column names had leading spaces in some instances, but read.csv<br>> would remove them.<br>><br>> I tried to read the file with fread and it was keeping the leading spaces.<br>> Here is dump of the session:<br>><br>>> positXY <- read.csv(positionFile, as.is = TRUE)<br>>><br>>><br>>> str(positXY)<br>> 'data.frame': 12 obs. of 8 variables:<br>> $ ieee : chr "1972cd01004b1200" "6375cd01004b1200"<br>> "5875cd01004b1200" "1972cd01004b1200" ...<br>> $ startTime : chr "13:46" "13:46" "13:46" "13:53" ... # no leading<br>> space on next three<br>> $ endTime : chr "13:51" "13:51" "13:51" "13:58" ...<br>> $ x : int 65 65 65 65 65 65 65 65 65 65 ...<br>> $ y : int 45 45 45 45 45 45 45 45 45 45 ...<br>> $ z : num 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 ...<br>> $ deviceDirection: chr "east" "west" "north" "south" ...<br>> $ test. : logi NA NA NA NA NA NA ...<br>>> positXY <- fread(positionFile)<br>>><br>>> str(positXY)<br>> Classes ‘data.table’ and 'data.frame': 12 obs. of 8 variables:<br>> $ ieee : chr "1972cd01004b1200" "6375cd01004b1200"<br>> "5875cd01004b1200" "1972cd01004b1200" ...<br>> $ startTime : chr "13:46" "13:46" "13:46" "13:53" ... # leading<br>> space on next three<br>> $ endTime : chr "13:51" "13:51" "13:51" "13:58" ...<br>> $ x : int 65 65 65 65 65 65 65 65 65 65 ...<br>> $ y : int 45 45 45 45 45 45 45 45 45 45 ...<br>> $ z : num 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4 ...<br>> $ deviceDirection: chr "east" "west" "north" "south" ...<br>> $ test# : int NA NA NA NA NA NA NA NA NA NA ...<br>> - attr(*, ".internal.selfref")=<externalptr><br>>> sessionInfo()<br>> R version 3.0.2 (2013-09-25)<br>> Platform: x86_64-w64-mingw32/x64 (64-bit)<br>><br>> locale:<br>> [1] LC_COLLATE=English_United States.1252<br>> [2] LC_CTYPE=English_United States.1252<br>> [3] LC_MONETARY=English_United States.1252<br>> [4] LC_NUMERIC=C<br>> [5] LC_TIME=English_United States.1252<br>><br>> attached base packages:<br>> [1] stats grDevices utils datasets graphics methods<br>> [7] base<br>><br>> other attached packages:<br>> [1] data.table_1.8.10 bitops_1.0-6<br>><br>> loaded via a namespace (and not attached):<br>> [1] tools_3.0.2<br>><br>><br>> Is it possible to have the leading spaces removed automatically, or via a<br>> parameter?<br>><br>><br>><br>> --<br>> View this message in context: http://r.789695.n4.nabble.com/leading-spaces-on-column-names-from-CSV-file-tp4683986.html<br>> Sent from the datatable-help mailing list archive at Nabble.com.<br>> _______________________________________________<br>> datatable-help mailing list<br>> datatable-help@lists.r-forge.r-project.org<br>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help<br><br></body>