perda.analyzer.csv#
- pydantic model perda.analyzer.csv.ParsedData[source]#
Bases:
BaseModel- Config:
arbitrary_types_allowed: bool = True
- Fields:
-
field timestamp_chunks:
dict[int,list[GenericAlias[int64]]] [Required]# Per-variable timestamp pieces, one per block the variable appears in
-
field value_chunks:
dict[int,list[GenericAlias[float64]]] [Required]# Per-variable value pieces, aligned with timestamp_chunks
-
field total_data_points:
int[Required]# Number of valid data rows
-
field data_start_time:
int[Required]# Earliest timestamp in the data
-
field data_end_time:
int[Required]# Latest timestamp in the data
-
field parsing_errors:
int[Required]# Number of rows dropped as unparseable
- pydantic model perda.analyzer.csv.ParsedVariableLine[source]#
Bases:
BaseModel-
field cpp_name:
str[Required]# C++ name of the variable
-
field description:
str[Required]# Human readable description of the variable
-
field var_id:
int[Required]# Numeric ID the data rows refer to
-
field cpp_name:
- pydantic model perda.analyzer.csv.VariableMappings[source]#
Bases:
BaseModel-
field id_to_cpp_name:
dict[int,str] [Required]# Mapping from variable ID to variable name
-
field id_to_descript:
dict[int,str] [Required]# Mapping from variable ID to variable description
-
field skip_rows:
int[Required]# Number of leading rows before the numeric data section
-
field id_to_cpp_name:
- perda.analyzer.csv.build_data_instances(mappings, parsed, verbose=1)[source]#
Join each variable’s pieces into one DataInstance per variable.
- Parameters:
mappings (VariableMappings) – Variable ID lookup tables.
parsed (ParsedData) – Per-variable data pieces. Pieces are removed as they are joined.
verbose (int, optional) – Verbosity level. 0 for no output, 2 for progress bars. Default is 1.
- Returns:
Mapping from variable ID to its DataInstance.
- Return type:
dict[int, DataInstance]
- perda.analyzer.csv.parse_csv(file_path, ts_offset=0, parsing_errors_limit=100, verbose=1, build_search_index=False)[source]#
Parse CSV file and return SingleRunData model.
- Parameters:
file_path (str) – Path to the CSV file to parse.
ts_offset (int, optional) – Timestamp offset applied to all data points. Default is 0.
parsing_errors_limit (int, optional) – Maximum number of parsing errors before stopping. -1 for no limit. Default is 100.
verbose (int, optional) – Verbosity level. 0 for no output, 1 for basic output, 2 for detailed output. Default is 1.
build_search_index (bool, optional) – Whether to vectorize variable descriptions for semantic search. Requires the
semanticextra and adds noticeable time to parsing. Default is False.
- Returns:
Parsed data structure containing all variables.
- Return type:
Notes
The timestamp unit is auto-detected from the header suffix: “v2.0” means microseconds, anything else means milliseconds.
- perda.analyzer.csv.parse_data_lines(file_path, skip_rows, ts_offset=0, parsing_errors_limit=100, verbose=1)[source]#
Read the numeric data section block by block, splitting it by variable ID.
- Parameters:
file_path (str) – Path to the CSV file to read.
skip_rows (int) – Number of leading rows to skip before the numeric data.
ts_offset (int, optional) – Timestamp offset applied to all data points. Default is 0.
parsing_errors_limit (int, optional) – Maximum number of malformed rows tolerated. -1 for no limit. Default is 100.
verbose (int, optional) – Verbosity level. 0 for no output, 1 or higher for status. Default is 1.
- Returns:
Per-variable data pieces and the count of malformed rows dropped.
- Return type:
- perda.analyzer.csv.parse_header_creation_time(header_line)[source]#
Extract the recording date from a log file’s first line.
- Parameters:
header_line (str) – First line of the log file, e.g.
"PER Log: Thu Jun 11 17:06:37 2026 v2.0".- Returns:
Parsed recording date, or None if the header carries no recognizable date.
- Return type:
datetime | None
- perda.analyzer.csv.parse_variable_id_mappings(file_handle, verbose=1)[source]#
Read the variable ID and name mapping lines that follow the file header.
- Parameters:
file_handle (TextIO) – Open log file positioned just after the header line.
verbose (int, optional) – Verbosity level. 0 for no output, 1 for warnings, 2 for progress bars. Default is 1.
- Returns:
Parsed lookup tables and the row offset where numeric data begins.
- Return type: