Learn R Programming

textreadr (version 1.2.0)

un_zip: Unzip/Unzip Files

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

un_zip(file, loc = dirname(file), ...)

un_tar(file, loc = dirname(file), ...)

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

Run this code
# 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()
# }

Run the code above in your browser using DataLab