Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script determines how many unmapped listings have 1-2 matches - which we could crowd source confirm the correct product to map.
import csv
unmapped_listings = 0
unmapped_listings_few_matches = 0
with open('lv-listings.csv') as csvfile:
data = csv.reader(csvfile, delimiter=',')
for row in data:
# Listing is missing a direct match loki_product_id.
if not row[11]:
unmapped_listings += 1
# Use eval instead of json.loads() since CSV contains invalid single-quote JSON.
matches = eval(row[5])
# Listing has 1-2 possible matches.
# @TODO: Set a minimum confidence threshold (0.6+)
if len(matches['product']) <= 2:
unmapped_listings_few_matches += 1
print("Unmapped Listings: %d" % unmapped_listings)
print("Unmapped Listings w/ 1-2 Possible Product Matches: {} ({:.0%})".format(unmapped_listings_few_matches, unmapped_listings_few_matches / unmapped_listings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.