I have a text file log2.log encoded Ansi in Windows. When I execute: out <- read.zoo(readLines(con <- file("log2.log", encoding="UCS-2LE")),FUN = as.chron) have errors: Error en file(file, "rt") : no se puede abrir la conexi?n Adem?s: Mensajes de aviso perdidos 1: In file(file, "rt") : s?lo fue usado el primer elemento del argumento 'description' 2: In file(file, "rt") : no fue posible abrir el archivo '#Software: Microsoft Internet Information Services 5.0': No such file or directory Why? Thks, Sebasti?n.
You've tried this? out <- read.zoo("log2.log", encoding="UCS-2LE", FUN = as.chron) On Wed, Jul 7, 2010 at 10:16 AM, Sebastian Kruk <residuo.solow@gmail.com>wrote:> I have a text file log2.log encoded Ansi in Windows. > > When I execute: > > out <- read.zoo(readLines(con <- file("log2.log", > encoding="UCS-2LE")),FUN = as.chron) > > have errors: > > Error en file(file, "rt") : no se puede abrir la conexión > Además: Mensajes de aviso perdidos > 1: In file(file, "rt") : > sólo fue usado el primer elemento del argumento 'description' > 2: In file(file, "rt") : > no fue posible abrir el archivo '#Software: Microsoft Internet > Information Services 5.0': No such file or directory > > Why? > > Thks, > > Sebastián. > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
On Wed, Jul 7, 2010 at 9:16 AM, Sebastian Kruk <residuo.solow at gmail.com> wrote:> I have a text file log2.log encoded Ansi in Windows. > > When I execute: > > out <- read.zoo(readLines(con <- file("log2.log", > encoding="UCS-2LE")),FUN = as.chron) > > have errors: > > Error en file(file, "rt") : no se puede abrir la conexi?n > Adem?s: Mensajes de aviso perdidos > 1: In file(file, "rt") : > ?s?lo fue usado el primer elemento del argumento 'description' > 2: In file(file, "rt") : > ?no fue posible abrir el archivo '#Software: Microsoft Internet > Information Services 5.0': No such file or directory > > Why? >The file argument of read.zoo is a character string giving the *name* of the file, not the contents of the file as a vector of character strings. Alternately it can be a connection (undocumented but works) or a data.frame so you likely want one of these: read.zoo(file("log2.log", encoding="UCS-2LE"), FUN = as.chron) read.zoo("log2.log", FUN = as.chron) See the examples section of ?read.zoo for more examples.
On 07/07/2010 9:16 AM, Sebastian Kruk wrote:> I have a text file log2.log encoded Ansi in Windows. >What Windows calls "Ansi" is called "latin1" in R. You said the encoding was "UCS-2LE", which Windows calls "Unicode". Part of your problem might be this mismatched encoding. Have you tried using encoding="latin1" when you read the file? Duncan Murdoch> When I execute: > > out <- read.zoo(readLines(con <- file("log2.log", > encoding="UCS-2LE")),FUN = as.chron) > > have errors: > > Error en file(file, "rt") : no se puede abrir la conexi?n > Adem?s: Mensajes de aviso perdidos > 1: In file(file, "rt") : > s?lo fue usado el primer elemento del argumento 'description' > 2: In file(file, "rt") : > no fue posible abrir el archivo '#Software: Microsoft Internet > Information Services 5.0': No such file or directory > > Why? > > Thks, > > Sebasti?n. > > ______________________________________________ > 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. >
>> I tried: >> >> L <- readLines(con <- file("log2.log", encoding="UCS-2LE") >> z <- read.zoo(textConnection(L), index = 1:2,FUN = function(x) >> paste(x[,1], x[,2])) >> >> Error: >> Error en x[, 1] : n?mero incorreto de dimensiones >>>Please provide a reproducible example like this:>library(zoo) >L <- "4/4/200 10:10:10 3000 >5/5/2000 12:12:12 4000" >read.zoo(textConnection(L), index = 1:2, FUN = function(x) >paste(x[,1], x[,2]))>which gives me>4/4/200 10:10:10 5/5/2000 12:12:12 > 3000 4000 1st line #Prueba Second line "04/04/200 10:10:10 3000 Juan" 2nd "05/05/2000 12:12:12 4000 -" ... 10th line: 05/04/2010 10:10:10 3000 Juan ... nth line "01/01/2009 21:10:10 50 Varela" ... last line "11/11/2008 23:20:32 5091 Laura" It's a window's unicode text file.