In R, how do I verify that write.csv(my.data.frame, file='test.csv')
was successful without re-reading it in again? It doesn't seem to return anything. I was thinking of doing a file.exists('test.csv')
and then grabbing a timestamp before and after the write.csv()
and checking that the timestamp on the file is between the two? Any suggestions?
You may use the function try()
:
res <- try(write.csv(1:100, "SOME GOOD PATH/temp.csv"))
is.null(res)
# [1] TRUE
res <- try(write.csv(1:100, "SOME BAD PATH/temp.csv"))
is.null(res)
# [1] FALSE
class(res)
# [1] "try-error"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With