un_zip: Unzip/Unzip Files

Description Usage Arguments Value See Also Examples

View source: R/un_zip.R

Description

Unzip/untar files and return the location of exit directory. This is a convenience function (wrapper for utils::unzip()) to make the function more pipe-able. Additionally, the location of the unzip defaults to the directory containing the zip file.

Usage

1
2
3

Arguments

file

Path to the zip file.

loc

The output directory location.

...

Other arguments passed to utils::unzip().

Value

Returns the path to where the zip file was unzipped to.

See Also

utils::unzip()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse)

dl_loc <- 'http://www.cs.uic.edu/~liub/FBS/CustomerReviewData.zip'  %>%
    download() %>%
    un_zip()


dir(dl_loc, pattern = '[Cc]ustomer')
dir(dl_loc, pattern = 'customer', full.names = TRUE)[1] %>%
    dir()

dir(dl_loc, pattern = 'customer', full.names = TRUE)[1] %>%
    dir(pattern = '\\.txt$', full.names = TRUE) 

dir(dl_loc, pattern = 'customer', full.names = TRUE)[1] %>%
    read_dir()


dir(dl_loc, pattern = 'customer', full.names = TRUE)[1] %>%
    dir(pattern = '\\.txt$', full.names = TRUE) %>%
    `[`(1) %>%
    read_document()

## End(Not run)

textreadr documentation built on Oct. 9, 2021, 5:06 p.m.