arkouda.io_util

Functions

delete_directory(→ None)

Deletes the directory if it exists.

delimited_file_to_dict(→ Dict[str, str])

Returns a dictionary populated by lines from a file where

dict_to_delimited_file(→ None)

Writes a dictionary to delimited lines in a file where

get_directory(→ pathlib.Path)

Creates the directory if it does not exist and then

write_line_to_file(→ None)

Writes a line to the requested file. Note: if the file

Module Contents

arkouda.io_util.delete_directory(dir: str) None[source]

Deletes the directory if it exists.

Parameters:

dir (str) – The path to the directory

Raises:

OSError – Raised if there’s an error in deleting the directory.

arkouda.io_util.delimited_file_to_dict(path: str, delimiter: str = ',') Dict[str, str][source]

Returns a dictionary populated by lines from a file where the first delimited element of each line is the key and the second delimited element is the value.

Parameters:
  • path (str) – Path to the file

  • delimiter (str) – Delimiter separating key and value

Returns:

Dictionary containing key,value pairs derived from each line of delimited strings

Return type:

Mapping[str,str]

Raises:

UnsupportedOperation – Raised if there’s an error in reading the file

arkouda.io_util.dict_to_delimited_file(path: str, values: Mapping[Any, Any], delimiter: str = ',') None[source]

Writes a dictionary to delimited lines in a file where the first delimited element of each line is the dict key and the second delimited element is the dict value. If the file does not exist, it is created and then written to.

Parameters:
  • path (str) – Path to the file

  • delimiter – Delimiter separating key and value

Return type:

None

Raises:
  • OError – Raised if there’s an error opening or writing to the specified file

  • ValueError – Raised if the delimiter is not supported

arkouda.io_util.get_directory(path: str) pathlib.Path[source]

Creates the directory if it does not exist and then returns the corresponding Path object

Parameters:

path (str) – The path to the directory

Returns:

Path object corresponding to the directory

Return type:

str

Raises:

ValueError – Raised if there’s an error in reading an existing directory or creating a new one

arkouda.io_util.write_line_to_file(path: str, line: str) None[source]

Writes a line to the requested file. Note: if the file does not exist, the file is created first and then the specified line is written to it.

Parameters:
  • path (str) – Path to the target file

  • line (str) – Line to be written to the file

Return type:

None

Raises:

UnsupportedOption – Raised if there’s an error in creating or writing to the file