arkouda.io_util

Functions

delete_directory(→ None)

Delete the directory if it exists.

delimited_file_to_dict(→ Dict[str, str])

Return a dictionary populated by lines from a file.

dict_to_delimited_file(→ None)

Write a dictionary to delimited lines in a file.

get_directory(→ pathlib.Path)

Create the directory if it does not exist and returns the corresponding Path object.

write_line_to_file(→ None)

Write a line to the requested file.

Package Contents

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

Delete 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]

Return a dictionary populated by lines from a file.

Return 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. If the file does not exist, return an empty dictionary.

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

  • ValueError – Raised if a line has more or fewer than two delimited elements

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

Write a dictionary to delimited lines in a file.

Write 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

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]

Create the directory if it does not exist and returns the corresponding Path object.

Parameters:

path (str) – The path to the directory

Returns:

Object corresponding to the directory

Return type:

Path

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]

Write 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

Raises:

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