data module

Read and write data to or from file.

Date

2019-07-29

fold_list(lst, n)[source]

Convert one-dimensional kx1 array (list) to two-dimensional mxn array. m = k / n

Parameters
  • lst (list) – list to convert

  • n (int) – length of the second dimenson

Returns

two-dimensional array (list of lists)

Return type

list

get_id(ids, uide)[source]

Get full id from unique id ending.

Parameters
  • ids (list) – ids

  • uide (str) – unique id ending

Returns

full id

Return type

str or int

load(file_name, default=None, verbose=False)[source]

Load stored program objects from binary file.

Parameters
  • file_name (str) – file to load

  • default (object) – return object if data loading fails

  • verbose (bool) – verbose information (default = False)

Returns

loaded data

Return type

object

read(file_name, x_column, y_column, default=None, verbose=False)[source]

Read ascii data file.

Parameters
  • filename (str) – file to read

  • x_column (int) – column index for the x data (first column is 0)

  • y_column (int) – column index for the y data (first column is 0)

  • default (object) – return object if data loading fails

  • verbose (bool) – verbose information (default = False)

Returns

x and y

Return type

tuple(list, list)

store(file_name, object_data)[source]

Store program objects to binary file.

Parameters
  • file_name (str) – file to store

  • object_data (object) – data to store

unique_ending(ids, n=1)[source]

From id list get list with unique ending.

Parameters
  • ids (list) – ids

  • n (int) – minumum chars or ints

Returns

unique ending of ids

Return type

list

write(file_name, data)[source]

Write ascii file.

Parameters
  • file_name (str) – file to write

  • data (str) – data to write