Skip to content

Instantly share code, notes, and snippets.

@dsposito
Last active April 24, 2019 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsposito/4289ff59f49ec4f5fc3e88ad0dc76ccc to your computer and use it in GitHub Desktop.
Save dsposito/4289ff59f49ec4f5fc3e88ad0dc76ccc to your computer and use it in GitHub Desktop.
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