[R] Data import export zipped files from URLs

0 views
Skip to first unread message

Velappan Periasamy

unread,
Jan 19, 2010, 1:27:49 AM1/19/10
to r-h...@r-project.org
I am not able to import zipped files from the following link.
How to get thw same in to R?.
mydata <- read.csv("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")

______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dieter Menne

unread,
Jan 19, 2010, 3:10:09 AM1/19/10
to r-h...@r-project.org

Velappan Periasamy wrote:
>
> I am not able to import zipped files from the following link.
> How to get thw same in to R?.
> mydata <-
> read.csv("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")
>

As Brian Ripley noted in

http://markmail.org/message/7dsauipzagq5y36o

you will have to download it first and then to unzip.

Dieter


--
View this message in context: http://n4.nabble.com/Data-import-export-zipped-files-from-URLs-tp1017287p1017326.html
Sent from the R help mailing list archive at Nabble.com.

Duncan Temple Lang

unread,
Jan 19, 2010, 7:58:17 AM1/19/10
to Dieter Menne, r-h...@r-project.org

Dieter Menne wrote:
>
> Velappan Periasamy wrote:
>> I am not able to import zipped files from the following link.
>> How to get thw same in to R?.
>> mydata <-
>> read.csv("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")
>>
>
> As Brian Ripley noted in
>
> http://markmail.org/message/7dsauipzagq5y36o
>
> you will have to download it first and then to unzip.

Well if downloading to disk first does need to be avoided, you can use
the RCurl and Rcompression packages to do the computations in memory:

library(RCurl)
ctnt = getURLContent("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")


library(Rcompression)
zz = zipArchive(ctnt)
names(zz)
txt = zz[[1]]
read.csv(textConnection(txt))

D.

>
> Dieter

Gabor Grothendieck

unread,
Jan 19, 2010, 8:06:55 AM1/19/10
to veep...@gmail.com, r-h...@r-project.org
If you need an example of this look at the yacasInstall function in this file:

http://ryacas.googlecode.com/svn/trunk/R/yacasInstall.R

from the Ryacas package. It downloads, unzips and installs yacas and
associated files for Windows users.

Velappan Periasamy

unread,
Jan 19, 2010, 11:56:12 AM1/19/10
to r-h...@r-project.org
How to unzip this file?.

> mydata <- unzip("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")
Warning message:
In unzip("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip")
:
error 1 in extracting from zip file

Henrique Dallazuanna

unread,
Jan 19, 2010, 12:30:39 PM1/19/10
to Velappan Periasamy, r-h...@r-project.org
Try this:

f <- tempfile()
download.file("http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip",
f)
myData <- read.csv(unzip(f))

--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

Velappan Periasamy

unread,
Jan 23, 2010, 3:37:49 AM1/23/10
to Henrique Dallazuanna, r-h...@r-project.org
cannot open: HTTP status was '404 Not Found' while running the
following commands

f <- tempfile()
download.file("http://nseindia.com/content/equities/scripvol/datafiles/01-01-2010-TO-23-01-2010RCOMXN.csv",
f)
myData <- read.csv(f)

Velappan Periasamy

unread,
Jan 23, 2010, 6:13:31 AM1/23/10
to Dennis Murphy, r-h...@r-project.org
The same link works and dowloads data while copying and pasteing the
link in firebox address box.
the file is there and the server is active.

Henrique Dallazuanna

unread,
Jan 23, 2010, 7:54:42 AM1/23/10
to Velappan Periasamy, r-h...@r-project.org
Your url is wrong. is missing ".zip" in the end.

See the code again.

Velappan Periasamy

unread,
Jan 23, 2010, 7:42:32 PM1/23/10
to Henrique Dallazuanna, r-h...@r-project.org
http://nseindia.com/content/equities/scripvol/datafiles/01-01-2010-TO-23-01-2010RCOMXN.csv


the url is correct. it is not zipped file.
copy the url in the browser window you will get the
this ......


Symbol,Series,Date, Prev Close,Open Price,High Price,Low Price,Last
Price,Close Price,Average Price,Total Traded Quantity,Turnover in
Lacs,
RCOM,EQ,04-Jan-2010,172.35,173,175.8,172.55,175.25,175.2,174.17,2418999,4213.1160435,
RCOM,EQ,05-Jan-2010,175.2,176,182,175.8,181.45,181.35,178.64,6033757,10778.7459905,
RCOM,EQ,06-Jan-2010,181.35,182.5,184.4,180.8,181.5,181.8,182.76,4680776,8554.525768,
RCOM,EQ,07-Jan-2010,181.8,183.7,185.3,182.5,183.8,183.9,184.05,4255338,7831.773937,
RCOM,EQ,08-Jan-2010,183.9,184.5,185.15,180.2,181.1,180.85,182.14,3775898,6877.5970215,
RCOM,EQ,11-Jan-2010,180.85,184,184,180.2,181.85,182.1,182.04,3601269,6555.8894695,
RCOM,EQ,12-Jan-2010,182.1,182.1,182.85,175.05,175.3,175.45,179.06,4834928,8657.6031315,
RCOM,EQ,13-Jan-2010,175.45,174,176.6,173.05,175.7,175.55,175.01,3276310,5733.8242525,
RCOM,EQ,14-Jan-2010,175.55,177.2,184.2,175.65,182.85,183,180.8,7227593,13067.2365775,
RCOM,EQ,15-Jan-2010,183,183,193.4,183,191.3,191.6,191.03,15459863,29533.7056915,
RCOM,EQ,18-Jan-2010,191.6,189.9,193.8,188.35,190.05,190.45,191.27,4710277,9009.3851875,
RCOM,EQ,19-Jan-2010,190.45,190,192.9,185.2,186.5,186.35,188.67,4458474,8411.945425,
RCOM,EQ,20-Jan-2010,186.35,187,190.6,185.3,186.6,186.9,188.05,3581194,6734.2921825,
RCOM,EQ,21-Jan-2010,186.9,186.85,189.75,184.15,185.3,185.15,186.85,3673061,6863.2499155,
RCOM,EQ,22-Jan-2010,185.15,183.7,184.7,176.45,181.6,181.55,181.5,4194634,7613.198626,

Peter Ehlers

unread,
Jan 24, 2010, 12:14:35 PM1/24/10
to Velappan Periasamy, r-h...@r-project.org
That's not the case for me:

Not Found
The requested object does not exist on this server. The link you
followed is either outdated, inaccurate, or the server has been
instructed not to let you have it.
Firefox 3.6

-Peter Ehlers

Henrique Dallazuanna

unread,
Jan 24, 2010, 7:29:25 PM1/24/10
to Peter Ehlers, r-h...@r-project.org, Velappan Periasamy
The same error for me:


"Not Found
The requested object does not exist on this server. The link you
followed is either outdated, inaccurate, or the server has been

instructed not to let you have it. Please inform the site
administrator of the referring page."

--

Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________

Reply all
Reply to author
Forward
0 new messages