.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Creating_GS_Files/help_I_have_no_variable_metadata.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_Creating_GS_Files_help_I_have_no_variable_metadata.py: Help! I have no metadata ------------------------ This example shows how GSPy can help when you have a large data file and need to do the tedious task of filling out the variable metadata. By doing a first-pass through GSPy with a data json file that is *missing* the ``variable_metadata`` dictionary, the code will break, but will generate a template file containing placeholder metadata dictionaries for all variables from the data file (in this case the column headers of the CSV data file). The user can then fill in this template and then add it to the data json file. This image shows a snippet of what the output template json file contains. Each variable is given a dictionary of attributes with the default values of "not_defined" which the user can then go through and update. .. GENERATED FROM PYTHON SOURCE LINES 18-24 .. code-block:: Python from os.path import join from gspy import Survey, Dataset import matplotlib.pyplot as plt from matplotlib import image as img .. GENERATED FROM PYTHON SOURCE LINES 25-27 Generate the Variable Metadata Template for My Dataset ++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 29-31 Zero existing metadata Initialize the Survey .. GENERATED FROM PYTHON SOURCE LINES 31-35 .. code-block:: Python template = Survey.metadata_template() template.dump("template_survey_empty.yml") .. GENERATED FROM PYTHON SOURCE LINES 36-38 Prefilled existing metadata file Path to example files .. GENERATED FROM PYTHON SOURCE LINES 38-47 .. code-block:: Python data_path = '..//..//..//..//example_material//example_2' # Define the Survey metadata file metadata = join(data_path, "data//Resolve_survey_md.yml") # Initialize the Survey template = Survey.metadata_template(metadata) template.dump("template_md_survey.yml") .. GENERATED FROM PYTHON SOURCE LINES 48-50 Define input data file (CSV format) and the associated metadata file (without the variable_metadata dictionary) .. GENERATED FROM PYTHON SOURCE LINES 50-59 .. code-block:: Python data = join(data_path, 'data//Resolve.csv') metadata = join(data_path, 'data//Resolve_data_md_without_variables.yml') template = Dataset.metadata_template(data) template.dump("template_md_resolve_empty.yml") template = Dataset.metadata_template(data, metadata) template.dump("template_md_resolve.yml") .. GENERATED FROM PYTHON SOURCE LINES 60-67 .. code-block:: Python data_path = '..//..//..//..//example_material//example_1' data = join(data_path, 'data//WI_SkyTEM_2021_ContractorData.csv') metadata = join(data_path, 'data//WI_SkyTEM_raw_data_md.yml') template = Dataset.metadata_template(data, metadata) template.dump("template_md_skytem.yml") .. GENERATED FROM PYTHON SOURCE LINES 68-69 Loupe Data .. GENERATED FROM PYTHON SOURCE LINES 69-76 .. code-block:: Python data_path = '..//..//..//..//example_material//example_3' data = join(data_path, 'data//Kankakee.dat') metadata = join(data_path, 'data//loupe_data_metadata.yml') template = Dataset.metadata_template(data_filename=data, metadata_file=metadata) template.dump("template_md_loupe.yml") .. _sphx_glr_download_examples_Creating_GS_Files_help_I_have_no_variable_metadata.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: help_I_have_no_variable_metadata.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: help_I_have_no_variable_metadata.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: help_I_have_no_variable_metadata.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_