[R] how can I import op.gz files with read.csv or otherwise
arun
smartpink111 at yahoo.com
Fri Dec 21 16:30:15 CET 2012
HI,
May be this link helps you:
http://stackoverflow.com/questions/5764499/decompress-gz-file-using-r
A.K.
----- Original Message -----
From: herr dittmann <herrdittmann at yahoo.co.uk>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc:
Sent: Friday, December 21, 2012 9:51 AM
Subject: [R] how can I import op.gz files with read.csv or otherwise
Dear R-users,
I am struggling to directly read an "op.gz" file into R. NOAA kindly provides daily weather data on their FTP server for download.
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_2.15.1
Here is the data set in question:
x <- read.csv(file="ftp://ftp.ncdc.noaa.gov/pub/data/gsod/2012/285880-99999-2012.op.gz", skip = 1, sep = "")
and "structure" returns some incomprehensible gibberish:
> str(x)
'data.frame': 70 obs. of 6 variables:
$ X4àtYd...ÂÚ8.åWD...ëü.ïß.X.QTñVP.. : Factor w/ 70 levels "\005~4èdŒÚíE\031y\020ÿíº\035JëïÒI˜Æí\021†BÆÌR{žYkv\035`“ì°a\017Z\021ÅsP’eÏhÞÇ""| __truncated__,..: 44 13 56 64 28 23 67 3 2 33 ...
$ X.öoMýßT..º_...Öígß7.â..Tþ.üÔ.ª...5ÕJ...žíÕj.QÊ..ã.eŃÎGmòýçºg..a...Õæ.J..Å.ãsç.êŠ.û.ÊklsUDÙ.Š..âU...u1.zË.WÜ..x...3._..E.ò.ÊZD.ïoÚÇ.dvæ....òk.C.y...8h: Factor w/ 41 levels "","\025ç\016\vβi;§4ƒñ\002\001P–á\0025¶•âÆ{ÐÄ™¹=¤4&ðw\\\\Q´›Ü´\"hnÅ™‰I¨ÅŠb*ªš\035b\b>6ÆÙ$W!ÖËR=¨\022“Pqˆ[»j\004$TÄ•3²*Ó±%àN”›\"| __truncated__,..: 1 1 1 39 1 1 1 8 1 5 ...
$ X.iŒ.yÐû..ý2.h..ûÉ7.ãJ.3k..jLm...Q..uYÓJä.K.zkU.8.öÖ..Y.7.3...üÊîA.Ê.3ûÄ..Z..5...âš. : Factor w/ 29 levels "","\001qË^+nê1",..: 1 1 1 4 1 1 1 14 1 6 ...
$ X.îFd.m.Š..v. : Factor w/ 17 levels ""," ´SL\ašÜÝ°\035d)‚¼$íZƼò¶îßJÉ‚äþ†B6å\006%5l[‘¼š\025a\024ñï+gT+3",..: 1 1 1 16 1 1 1 1 1 1 ...
$ ÿA..E.ŸJkEZ.ÐÊ.á.ë.......œ.z..Â.z..œ..òË.ÙÖãg.ö : Factor w/ 8 levels "","\001S\177¿\017iSÞÖiÓÈ#\017\"UgË:i´í\016pÝ\031UÄéD""| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
$ X..oðçnPÔoÎWõj.éÔ..B..Âÿë.Qêù...ø
While I can manually open and read the op.gz file in a text editor, read.csv() or read.table() the imported file is simply unreadable.
How can I best get the job done? Any pointers, suggestions, ideas most welcome!!
Thanks in advance!
Bernd
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list