File tree Expand file tree Collapse file tree
src/mindlogger_data_export Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,6 +143,17 @@ class TypedResponseStructProcessor(ReportProcessor):
143143 PRIORITY = 40
144144
145145 def _run (self , report : pl .DataFrame ) -> pl .DataFrame :
146+ def parse_with_nulls (d ) -> dict | None :
147+ """Parse with None fallback for null values."""
148+ response = d ["response" ]
149+ if (
150+ not response
151+ or response .strip () in ("" , "null" , "None" )
152+ or "value: null" in response
153+ ):
154+ return None
155+ return self .PARSER .parse_typed (d ["item_type" ], response )
156+
146157 return report .with_columns (
147158 response = pl .struct (
148159 status = pl .col ("item_response_status" ),
@@ -152,7 +163,7 @@ def _run(self, report: pl.DataFrame) -> pl.DataFrame:
152163 item_type = pl .col ("item" ).struct .field ("type" ),
153164 response = pl .col ("item_response" ).str .strip_chars (),
154165 ).map_elements (
155- lambda d : self . PARSER . parse_typed ( d [ "item_type" ], d [ "response" ]) ,
166+ parse_with_nulls ,
156167 schema .RESPONSE_VALUE_SCHEMA ,
157168 ),
158169 )
You can’t perform that action at this time.
0 commit comments