ladybug.datautil module

Utilities for serializing Data Collections to and from files.

ladybug.datautil.collections_from_csv(data_file)[source]

Load a series of Data Collections from a JSON file.

Parameters:

data_file – Path to a .json file containing a list of data collections.

Returns:

A list of data collections loaded from the .json file.

ladybug.datautil.collections_from_json(data_file)[source]

Load a series of Data Collections from a JSON file.

Parameters:

data_file – Path to a .json file containing a list of data collections.

Returns:

A list of data collections loaded from the .json file.

ladybug.datautil.collections_from_pkl(data_file)[source]

Load a series of Data Collections from a PKL file.

Parameters:

data_file – Path to a .pkl file containing a list of data collections.

Returns:

A list of data collections loaded from the .pkl file.

ladybug.datautil.collections_to_csv(data_collections, folder, file_name='data.csv')[source]

Write a series of aligned Data Collections into a CSV.

These can be serialized back to the original objects using the collections_from_csv method.

Parameters:
  • data_collections – A list of aligned Data Collections which will be written to a CSV.

  • folder – Folder to which the CSV will be written.

  • file_name – File name for the CSV (Default: data.csv).

Returns:

The path to the CSV file to which the data_collections have been written.

ladybug.datautil.collections_to_json(data_collections, folder, file_name='data.json', indent=None)[source]

Write a series of Data Collections into a JSON.

These can be serialized back to the original objects using the collections_from_json method.

Parameters:
  • data_collections – A list of aligned Data Collections which will be written to a JSON.

  • folder – Folder to which the JSON will be written.

  • file_name – File name for the JSON (Default: data.json).

  • indent – A positive integer to set the indentation used in the resulting JSON file. (Default: None).

Returns:

The path to the JSON file to which the data_collections have been written.

ladybug.datautil.collections_to_pkl(data_collections, folder, file_name='data.pkl')[source]

Write a series of Data Collections into a PKL.

These can be serialized back to the original objects using the collections_from_pkl method.

Parameters:
  • data_collections – A list of aligned Data Collections which will be written to a PKL.

  • folder – Folder to which the PKL will be written.

  • file_name – File name for the PKL (Default: data.pkl).

  • indent – A positive integer to set the indentation used in the resulting PKL file. (Default: None).

Returns:

The path to the PKL file to which the data_collections have been written.