metobs_toolkit.Dataset.write_to_csv#

Dataset.write_to_csv(obstype=None, filename=None, include_outliers=True, include_fill_values=True, add_final_labels=True, use_tlk_obsnames=True, overwrite_outliers_by_gaps_and_missing=True, seperate_metadata_file=True)[source]#

Write Dataset to a csv file.

Write the dataset to a file where the observations, metadata and (if available) the quality labels per observation type are merged together.

A final qualty control label for each quality-controlled-observation type can be added in the outputfile.

The file will be written to the outputfolder specified in the settings.

Parameters:
  • obstype (string, optional) – Specify an observation type to subset all observations to. If None, all available observation types are written to file. The default is None.

  • filename (string, optional) – The name of the output csv file. If none, a standard-filename is generated based on the period of data. The default is None.

  • include_outliers (bool, optional) – If True, the outliers will be present in the csv file. The default is True.

  • include_fill_values (bool, optional) – If True, the filled gap and missing observation values will be present in the csv file. The default is True.

  • add_final_labels (bool, optional) – If True, a column is added containing the final label of an observation. The default is True.

  • use_tlk_obsnames (bool, optional) – If True, the standard naming of the metobs_toolkit is used, else the original names for obstypes is used. The default is True.

  • overwrite_outliers_by_gaps_and_missing (bool, optional) – If the gaps and missing observations are updated using outliers, interpret these records as gaps/missing outliers if True. Else these will be interpreted as outliers. The default is True.

  • seperate_metadata_file (bool, optional) – If true, the metadat is written to a seperate file, else the metadata is merged to the observation in one file. The default is True.

Return type:

None.

Examples

>>> import metobs_toolkit
>>> import os
>>>
>>> # Import data into a Dataset
>>> dataset = metobs_toolkit.Dataset()
>>> dataset.update_settings(
...            input_data_file=metobs_toolkit.demo_datafile,
...            input_metadata_file=metobs_toolkit.demo_metadatafile,
...            template_file=metobs_toolkit.demo_template)
>>>
>>> dataset.import_data_from_file()
>>>
>>> # Save dataset to a .csv file
>>> dataset.update_settings(output_folder = os.getcwd())
>>> dataset.write_to_csv(filename='your_saved_table.csv')
write metadata to file: ...
write dataset to file: ...