fix: keep all fields and sanitize the CSV header in export_csv - #55
Open
chiruu12 wants to merge 1 commit into
Open
fix: keep all fields and sanitize the CSV header in export_csv#55chiruu12 wants to merge 1 commit into
chiruu12 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two issues in
export_csv.Dropped columns (#53). The column list came from
data[0].keys(), so a key that first appears on a later record was never written and nothing was raised. Scraper output is heterogeneous, optional fields are absent when a page does not have them, so this loses real data on ordinary output.export_jsonandexport_jsonlkeep every key, so the same result set exported differently depending on format. Columns now come from every record, in first-seen order.Unsanitized header (#54). #52 added
_sanitize_csv_cellfor values, butwriteheader()wrote the field names unchanged, and those names come from keys in the scraped payload. A key like=HYPERLINK("http://evil","x")still evaluated on open. The header now goes through the same sanitizer, including whenfields=is passed explicitly.sanitize=Falseleaves the header byte-exact as before.Tests: 5 new cases, 21 passing in the two export_csv files. Each new case fails with the source change reverted and the tests kept.