<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">I was trying to use fread() to read data when I got the following error which made no sense:<br style="" class=""><br style="" class=""><span class="" style="border-collapse: separate; color: rgb(248, 248, 248); font-family: 'Lucida Console'; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 15px; orphans: 2; text-align: -webkit-left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(20, 20, 20)"><pre tabindex="0" class="" style="font-family: 'Lucida Console'; font-size: 10pt
!important; outline-style: none; outline-width: initial; outline-color: initial; border-width: initial; border-color: initial; white-space: pre-wrap !important; word-break: break-all; -webkit-user-select: text; line-height: 1.2"><span class="" style="color: rgb(207, 106, 76)">In fread(paste0(strData, collapse = "\n"), integer64 = "character") :
Bumped column 2 to type character on data row 13, field contains '2464.77'. Coercing previously read values in this column from integer or numeric back to character which may not be lossless; e.g., if '00' and '000' occurred before they will now be just '0', and there may be inconsistencies with treatment of ',,' and ',NA,' too (if they occurred in this column before the bump). If this matters please rerun and set 'colClasses' to 'character' for this column. Please note that column type detection uses the first 5 rows, the middle 5 rows and the last 5 rows, so hopefully this message should be very rare. If reporting to datatable-help, please rerun and include the output from verbose=TRUE.</span></pre></span>because "2464.77" is a perfectly legitimate number and there is no reason to coerce the column to character for that.<br style="" class=""><br style="" class="">Here is how to reproduce it:<br style="" class=""><br style="" class=""> dtT
<- data.table( a = 1:72, b=0 )<br style="" class=""> dtT[ 13, b := 2464.77 ]<br style="" class=""><br style="" class=""> strData <- capture.output( write.table( dtT, row.names=FALSE, quote=FALSE, sep="\t" ) )<br style="" class=""> fread( paste0( strData, collapse="\n" ), integer64="character" )<br style="" class=""><br style="" class=""><div style="" class="">Note that the following works okay without the integer64="character" argument:</div><div style="" class=""> dtT <- data.table( a = 1:72, b=0 )<br style="" class=""> dtT[ 13, b := 2464.77 ]<br style="" class=""><br style="" class=""> strData <- capture.output( write.table( dtT, row.names=FALSE, quote=FALSE, sep="\t" ) )<br style="" class=""> fread( paste0( strData, collapse="\n" ) )</div><div style="" class=""><br></div><div style="" class="">I would appreciate if you could provide some sort of a
workaround for this. The reason I am using the integer64="character" argument is that I have large numbers at times which seems to be having issues once it is read as integer64 -- and that might have nothing to do with data.table but I have not had time to look into it. My work-around for that issue was to read it as character, but I run into the above issue.<br></div><div style="" class=""><br></div><div style="" class="">Thanks for your help.<br></div><div style="" class=""><br></div><div style="" class="">Regards,</div><div style="" class="">Harish</div><div style="" class=""><br></div><div style="" class=""><br style="" class=""></div></div></body></html>