Extract variables from files
el_paso.extract_variables_from_files.extract_variables_from_files
extract_variables_from_files
Extract variable data from files with any file format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
datetime
|
The start time for data extraction. |
required |
end_time
|
datetime
|
The end time for data extraction. |
required |
file_cadence
|
Literal['daily', 'monthly', 'single_file']
|
The cadence at which files are organized. |
required |
data_path
|
Path or str
|
The directory path where data files are stored. |
required |
file_name_stem
|
str
|
The stem of the file name to match files. |
required |
extraction_infos
|
Iterable[ExtractionInfo]
|
Information about which variables to extract and how. |
required |
pd_read_csv_kwargs
|
dict[str, Any]
|
Additional keyword arguments to pass to pandas.read_csv. |
None
|
custom_extractors
|
dict[str, Callable]
|
A dictionary mapping file suffixes to custom extractor functions. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Variable]
|
dict[str, Variable]: A dictionary mapping result keys to extracted Variable objects. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no files are found for extraction. |
Source code in el_paso/extract_variables_from_files.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
el_paso.extract_variables_from_files.ExtractionInfo
dataclass
Store metadata required to extract a variable from a source file.
Attributes:
| Name | Type | Description |
|---|---|---|
name_or_column |
str | int
|
Name of the variable or column to extract from the source file. |
unit |
UnitBase
|
Physical unit associated with the extracted variable. |
is_time_dependent |
bool
|
Whether the variable is time-dependent. If If |
result_key |
str | None
|
Key to use for the extracted variable in the resulting variables dictionary. If |
dependent_variables |
list[str] | None
|
Names of variables that the extracted variable depends on. This is mainly used for JSON extraction to determine how extracted data should be reshaped. |
np_dtype |
DTypeLike | None
|
Optional NumPy dtype used to cast the extracted data. If |
Source code in el_paso/extract_variables_from_files.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |