Skip to content

fread locks file if it encounters an error (Windows) #2044

@HughParsonage

Description

@HughParsonage

This seems to reopen a previously solved issue: https://stackoverflow.com/questions/18597123/fread-data-table-locks-files

Given an improperly written csv (empty-field.csv):

X,Y
1,2
3,4,
5,6

When I run:

library(data.table)
fread("empty-field.csv")

I get the error (as expected):

Error in fread("~/sandbox/empty-field.csv") :
Expecting 2 cols, but line 3 contains text after processing all cols. Try again with fill=TRUE. Another reason could be that fread's logic in distinguishing one or more fields having embedded sep=',' and/or (unescaped) '\n' characters within unbalanced unescaped quotes has failed. If quote='' doesn't help, please file an issue to figure out if the logic could be improved.

However, when I go to edit empty-field.csv (in Sublime Text 3), I get the error message

Unable to save empty-field.csv
Error: The requested operation cannot be performed on a file with a user-mapped section open.

Closing and reopening Sublime Text 3 does not solve the problem: R has to be closed. I encounter a similar error message with Notepad++, but I do not encounter any problems with Notepad.

I'm using the dev version: data.table 1.10.5 IN DEVELOPMENT built 2017-02-09 02:16:47 UTC; travis

sessionInfo()

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions