Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch csv generation to QUOTE_MINIMAL #117

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/handlers/site_upload/powerset_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ def generate_csv_from_parquet(bucket_name: str, bucket_root: str, subbucket_path
last_valid_df = last_valid_df.apply(
lambda x: x.strip() if isinstance(x, str) else x
).replace('""', numpy.nan)
# Here we are removing internal commas from fields so we get a valid unquoted CSV
last_valid_df = last_valid_df.replace(to_replace=",", value="", regex=True)
awswrangler.s3.to_csv(
last_valid_df,
(
Expand All @@ -238,7 +236,7 @@ def generate_csv_from_parquet(bucket_name: str, bucket_root: str, subbucket_path
)
),
index=False,
quoting=csv.QUOTE_NONE,
quoting=csv.QUOTE_MINIMAL,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/site_upload/test_powerset_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def test_parquet_to_csv(mock_bucket):
)
assert list(df["race"].dropna().unique()) == [
"White",
"Black or African American",
"Black, or African American",
"Asian",
"American Indian or Alaska Native",
"American Indian, or Alaska Native",
]
Loading