Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check file size before opening?

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.

like image 950
Rhodo Avatar asked Jun 01 '15 18:06

Rhodo


People also ask

How do I know the size of a file before downloading?

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.

How do you check file size?

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.

How do I see file size in Windows?

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.


2 Answers

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 
like image 180
Andrie Avatar answered Sep 21 '22 14:09

Andrie


library(RCurl) url = "http://math.ucdenver.edu/RTutorial/titanic.txt" xx = getURL(url, nobody=1L, header=1L) strsplit(xx, "\r\n") 
like image 22
Anthony Damico Avatar answered Sep 23 '22 14:09

Anthony Damico