Skip to content

Commit f2485e8

Browse files
authored
Merge pull request #7 from avdata99/fix_bad_mean_for_dates
start proposal
2 parents ce40cfc + 32a91b9 commit f2485e8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ckanext/datapusher_plus/jobs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,22 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
11741174
if conf.AUTO_INDEX_THRESHOLD:
11751175
headers_cardinality.append(int(fr.get("cardinality") or 0))
11761176

1177+
# Go through the qsv_stats_csv file and ensure the "mean" field is empty for
1178+
# field of type "Date"
1179+
new_qsv_stats_csv = os.path.join(temp_dir, "qsv_stats_cleaned.csv")
1180+
with open(qsv_stats_csv, mode="r") as inp, open(new_qsv_stats_csv, mode="w") as outp:
1181+
reader = csv.DictReader(inp)
1182+
fieldnames = reader.fieldnames
1183+
writer = csv.DictWriter(outp, fieldnames=fieldnames)
1184+
writer.writeheader()
1185+
for row in reader:
1186+
if row["type"] == "Date" or row["type"] == "DateTime":
1187+
row["mean"] = ""
1188+
writer.writerow(row)
1189+
qsv_stats_csv = new_qsv_stats_csv
1190+
logger.info(f"New qsv_stats_csv types for {qsv_stats_csv}")
1191+
print(open(qsv_stats_csv).read())
1192+
11771193
# Get the field stats for each field in the headers list
11781194
existing = datastore_resource_exists(resource_id)
11791195
existing_info = None

0 commit comments

Comments
 (0)