Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fread (data.table) locks files

Tags:

r

data.table

I have used fread from data.table package and when I try to modify or delete the file (just open with notepad) windows says:

enter image description here

How can I unlock this binding?

edit:

trying in R gives the same

cat(file="C:/Users/MCarrie/Desktop/test/test2.txt")
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Users/MCarrie/Desktop/test/test2.txt': Permission denied

info:

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.8.8

loaded via a namespace (and not attached):
[1] tools_3.0.1

> showConnections(all=T)
  description class      mode text   isopen   can read can write
0 "stdin"     "terminal" "r"  "text" "opened" "yes"    "no"     
1 "stdout"    "terminal" "w"  "text" "opened" "no"     "yes"    
2 "stderr"    "terminal" "w"  "text" "opened" "no"     "yes"  

file being read: (missing quote put on purpose)

"AA",3,4,5,"w"
"ss,2,3,4,"s"
"ww",2,3,3,"s"
like image 732
nigmastar Avatar asked Sep 03 '13 16:09

nigmastar


1 Answers

Please retry with data.table v1.8.11. There's a new .zip for Windows on the data.table homepage.

From NEWS :

If fread returns a data error (such as unbalanced quotes on a particular line) it now closes the file first rather than holding a lock open, a Windows only problem. Thanks to nigmastar for reporting and Carl Witthoft for the hint. Tests added.

like image 170
Matt Dowle Avatar answered Nov 15 '22 09:11

Matt Dowle