How can I check the size of a file before I load it into R?
For example:
http://math.ucdenver.edu/RTutorial/titanic.txt
I'd like to use the optimal command to open a file based on the file's size.
you can get a header called Content-Length form the HTTP Response object that you get, this will give you the length of the file. you should note though, that some servers don't return that information, and the only way to know the actual size is to read everything from the response.
Locate the file or folder whose size you would like to view. Click the file or folder. Press Command + I on your keyboard. A window opens and shows the size of the file or folder.
Go to Windows Explorer and right-click on the file, folder or drive that you're investigating. From the menu that appears, go to Properties. This will show you the total file/drive size.
Use file.info()
file.info("data/ullyses.txt") size isdir mode mtime ctime atime uid gid data/ullyses.txt 1573151 FALSE 664 2015-06-01 15:25:55 2015-06-01 15:25:55 2015-06-01 15:25:55 1008 1008
Then extract the column called size
:
file.info("data/ullyses.txt")$size [1] 1573151
library(RCurl) url = "http://math.ucdenver.edu/RTutorial/titanic.txt" xx = getURL(url, nobody=1L, header=1L) strsplit(xx, "\r\n")
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