Access CSV Data Files#
In most cases measurement data files are of CSV format, but vary in formatting like header, delimiter and other. However, the basic structure is common, so you can modify an existing plugin and adapt it to your needs - which in some cases only requires changing a few lines of code.
In this chapter we will explain how to modify and adapt an existing EXD-API Plugin to your needs.
Structure of EXD-API Plugins#
EXD-API Plugins are gRPC services that exposing data according to the ASAM ODS standard. You can find the respective gRPC definition file (.proto file) in the ASAM GitHub repository.
Python offers a straightforward way to generate server code from these definitions, which is the approach used in our EXD‑API Plugins. To explore different implementation possibilities, you can browse the publicly available EXD‑API Plugins in the Peak Solution GitHub repository.
To simplify working with spreadsheet-like data, our EXD‑API Plugins cache file contents in pandas.DataFrame objects, making data access more convenient.
Finally, we also leverage pandas’ powerful CSV reader to extract data efficiently from CSV files.
Typical structure of our EXD‑API Plugins:
exd_api_server.py
Runs the gRPC service exposing data according to the ASAM ODS standard.external_data_reader.py
Implements the EXD-API interface to allow simple pandas.DataFrame implementations. It includes data conversion and caching. The CSV implementation is given inexternal_file_data.py.external_file_data.py
Reads CSV files into pandas.DataFrames.
Because the implementation of the gRPC service and the need for caching and data conversion stays the same, the only file to modify and adapt is external_file_data.py.
Integrate your CSV file data#
You can now start adapting external_file_data.py to your needs. We use the ASAM ODS EXD-API CSV plugin as basis for our modifications.
Simple example#
The simplest example is changing the format parameters of pandas.read_csv used by that plugin:
‘self.__df = pd.read_csv(self.__file_path, **self.__parameters)’ (…)
For instance if your files are semicolon separated (common in EU locales) you can change this line to:
‘self.__df = pd.read_csv(self.__file_path, sep=”;”)’
For more information on using read_csv look into the pandas.read_csv — pandas documentation
Advanced examples#
In our simple example, all data (including channel names) is extracted from the pandas.DataFrame. In some situation you may want to return additional meta data by your plugin:
Channel names, units and descriptions#
Channel names
Implement ‘def column_names(self)’ to return channel names other than in pandas.DataFrame:
‘def column_names(self) -> list[str] | None:’ (…)Units
Implement ‘def column_units(self)’ to return engineering unit names for the individual channels:
‘def column_units(self) -> list[str] | None:’ (…)Description
Implement ‘def column_descriptions(self)’ to return additional descriptions for the individual channels:
‘def column_descriptions(self) -> list[str] | None:’ (…)
Additional attributes#
Furthermore, your plugin can provide additional information for data queries and analysis in form of name value pairs:
‘def group_attributes(self) -> dict | None:’ (…)
License#
Copyright © 2025 Peak Solution GmbH
The training material in this repository is licensed under a Creative Commons BY-NC-SA 4.0 license. See LICENSE file for more information.
Notebook: 📓 Back to course overview