Xlsxir v1.2.0 Xlsxir.Unzip
Provides validation of accepted file extension types for file path, extracts required .xlsx
contents to ./temp
and ultimately deletes the ./temp
directory and its contents.
Summary
Functions
Deletes all files and directories contained in specified directory
Extracts requested list of files from a .zip
file to ./temp
and returns a list of the extracted file paths
Validates given path is of extension type .xlsx
and returns a tuple
List of files contained in the requested .xlsx
file to be extracted
Functions
Deletes all files and directories contained in specified directory.
Parameters
dir
- list of directories to delete (default set for standard Xlsxir functionality)
Example
An example file named test.zip
located in ‘./test_data/test’ containing a single file named test.txt
:
iex> path = "./test/test_data/test.zip"
iex> file_list = ['test.txt']
iex> Xlsxir.Unzip.extract_xml_to_file(file_list, path)
{:ok, ['temp/test.txt']}
iex> Xlsxir.Unzip.delete_dir(["./temp"])
:ok
Extracts requested list of files from a .zip
file to ./temp
and returns a list of the extracted file paths.
Parameters
file_list
- list containing file paths to be extracted inchar_list
formatpath
- file path of a.xlsx
file type instring
format
Example
An example file named test.zip
located in ‘./test_data/test’ containing a single file named test.txt
:
iex> path = "./test/test_data/test.zip"
iex> file_list = ['test.txt']
iex> Xlsxir.Unzip.extract_xml_to_file(file_list, path)
{:ok, ['temp/test.txt']}
iex> File.ls("./temp")
{:ok, ["test.txt"]}
iex> Xlsxir.Unzip.delete_dir(["./temp"])
:ok
Validates given path is of extension type .xlsx
and returns a tuple.
Parameters
path
- file path of a.xlsx
file type instring
format
Example
iex> path = "Good_Example.xlsx"
iex> Xlsxir.Unzip.validate_path(path)
{:ok, 'Good_Example.xlsx'}
iex> path = "bad_path.xml"
iex> Xlsxir.Unzip.validate_path(path)
{:error, "Invalid path. Currently only .xlsx file types are supported."}