Skip to content

xlsx export: emit empty string instead of NaN for sites missing query_time#3013

Open
HrachShah wants to merge 1 commit into
sherlock-project:masterfrom
HrachShah:fix/xlsx-response-time-none-v2
Open

xlsx export: emit empty string instead of NaN for sites missing query_time#3013
HrachShah wants to merge 1 commit into
sherlock-project:masterfrom
HrachShah:fix/xlsx-response-time-none-v2

Conversation

@HrachShah

Copy link
Copy Markdown

The xlsx branch of main() has a dead if response_time_s is None check. response_time_s is initialized as a list 4 lines earlier, so it is never None and the else branch always runs — appending status.query_time directly. When a site has query_time = None (the documented default for an unread result), the appended None is written into a pandas column that gets cast to a numeric type by to_excel, producing NaN in the cell instead of the empty string the CSV branch emits for the same case.

Fix: Read status.query_time into a local query_time, then check if query_time is None and append "" in the None case, mirroring the existing CSV branch.

Verified: Simulated with a list of mixed [0.123, None, 0.456, None] query_times. Before: [0.123, NaN, 0.456, NaN]. After: [0.123, '', 0.456, ''] — matching the CSV branch's output for the same input.

In the --xlsx branch of main(), the `response_time_s = []` list was
initialized four lines above the per-site loop, so the `if response_time_s
is None` guard was a dead branch. The `else` always ran and appended
`results[site]["status"].query_time` directly. When the per-site query
time was None (which happens whenever the request errored out before
attaching an `.elapsed` attribute, or whenever the Future was None),
None got pushed into the list. The resulting DataFrame.column then
contained NaN in those rows, instead of the empty string the --csv
branch produces in the same situation, and instead of the string the
comment block at the top of the loop implied the xlsx branch was
trying to produce. Read the per-site query_time once, fall back to an
empty string when it's None, and append that to the list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant