Skip to content

studenac: extract archive with zipfile instead of subprocess unzip - #109

Open
Silenco22 wants to merge 4 commits into
senko:mainfrom
Silenco22:studenac-zipfile-fix
Open

Silenco22 wants to merge 4 commits into
senko:mainfrom
Silenco22:studenac-zipfile-fix

Conversation

@Silenco22

Copy link
Copy Markdown

The unzip subprocess exits non-zero with a warning on Studenac's archives, and the error path then does print(result.stderr.decode()). Studenac's stderr contains a non-UTF-8 byte (0xee), so that decode raises UnicodeDecodeError, the crawl chain swallows it, and Studenac silently yields zero products.

Use zipfile instead: no subprocess, no stderr decoding, and CP437-encoded member names (written by some ZIP writers) are decoded explicitly.

The unzip subprocess exits non-zero with a warning on Studenac's archives,
and the error path then does print(result.stderr.decode()). Studenac's
stderr contains a non-UTF-8 byte (0xee), so that decode raises
UnicodeDecodeError, the crawl chain swallows it, and Studenac silently
yields zero products.

Use zipfile instead: no subprocess, no stderr decoding, and CP437-encoded
member names (written by some ZIP writers) are decoded explicitly.
@senko

senko commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Note we do this intentionally: see b9cf6bc and 7fbe413

In cijene.dev prod (Debian 12), the current main successfully unpacks the file and imports studenac stores.

Boso publishes "Najniža cijena u poslj. 30 dana", but the abbreviated column
name was never mapped, so 10,295 promo rows a day arrived with no Omnibus
reference and could never surface as an akcija. 1,223 of them are provable
discounts (KOBAS GAVRI ČAJNA MAXI: 15.50 against a 30-day low of 18.43).

fix_product_data also substituted unit_price when a retailer published no
shelf price, which writes a per-kg figure into a per-package field: ARIEL
0,85 l was stored at 8223.53 instead of 12.66, across 291 trgocentar rows a
day with ratios up to 650x. A row with no published price now yields no
product rather than a wrong one.

unit_price is no longer back-filled from price either, so null means "the
chain did not publish a per-unit price" and the value can be trusted for
per-gram maths. branka and zabac aliased MPC into it, which would have stored
shelf prices as per-unit prices; both aliases are dropped, and since their
price fields already map MPC directly, parsing is unchanged.
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.

2 participants