Re: [R] How to read from a file within a gzipped file

2021-10-11 Thread Rui Barradas

Hello,

You can create a connection and read from it.

desc <- "X:/Mkt Science/Projects/ tv/202109.ext/tsa.20210901.xml.zip"
fname <- "20210901.socioDemos.a.xml"
zz <- unz(desc, fname)


Now read from zz. Example:


xml <- XML::xmlParse(zz)


Hope this helps,

Rui Barradas

Às 17:24 de 11/10/21, Conklin, Mike (GfK) via R-help escreveu:


Hi have a large number of zipped files, each containing 3 xml files that I want 
to read.  I would like to read one of the xml files without having to 
decompress each zip file first.

If I run gzfile(path2zipped file) I get

A connection with
description "X:/Mkt Science/Projects/ tv/202109.ext/tsa.20210901.xml.zip"
class   "gzfile"
mode"rb"
text"text"
opened  "closed"
can read"yes"
can write   "yes"

Within that zipped file I want to read from

"20210901.socioDemos.a.xml" which is one of 3 xml files within the zip file



Is there a way to return a connection to a single file within a zipped file 
using gzfile or some other method.



--
W. Michael Conklin
Executive Vice President
Marketing & Data Sciences - North America
GfK
mike.conk...@gfk.com
M +1 612 567 8287
www.gfk.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] How to read from a file within a gzipped file

2021-10-11 Thread Ivan Krylov
On Mon, 11 Oct 2021 16:24:01 +
"Conklin, Mike (GfK) via R-help"  wrote:

> Is there a way to return a connection to a single file within a
> zipped file using gzfile or some other method.

Sure! Use unz() instead of gzfile().

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] How to read from a file within a gzipped file

2021-10-11 Thread Conklin, Mike (GfK) via R-help


Hi have a large number of zipped files, each containing 3 xml files that I want 
to read.  I would like to read one of the xml files without having to 
decompress each zip file first.

If I run gzfile(path2zipped file) I get

A connection with
description "X:/Mkt Science/Projects/ tv/202109.ext/tsa.20210901.xml.zip"
class   "gzfile"
mode"rb"
text"text"
opened  "closed"
can read"yes"
can write   "yes"

Within that zipped file I want to read from

"20210901.socioDemos.a.xml" which is one of 3 xml files within the zip file



Is there a way to return a connection to a single file within a zipped file 
using gzfile or some other method.



--
W. Michael Conklin
Executive Vice President
Marketing & Data Sciences - North America
GfK
mike.conk...@gfk.com
M +1 612 567 8287
www.gfk.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.