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