Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:25:11+00:00 2026-06-18T12:25:11+00:00

I have 2 csv files. The first, input , consists of input street addresses

  • 0

I have 2 csv files. The first, input, consists of input street addresses with various errors. The second, ref is a clean street address table. Records within input need to be matched to records within ref. Converting the files to lists with unique records is fast, but once I get to the matching process, it’s dreadfully slow, taking a full 85 seconds just to match two addresses within input to ref without any regular expressions! I realize that the size of ref is the issue here; it is over 1 million records in length and the file size is 30 MB. I was anticipating some performance issues with these kinds of sizes, but taking this long for only two records is unacceptable (realistically, I may have to match up to 10,000 records or more. Additionally, I will eventually need to embed some regex to ref items to allow for more flexible matching. Testing the new regex module is even worse, taking a whopping 185 seconds for the same two input records. Does anybody know the best way to speed things up substantially? Can I somehow index by zip code, for example?

Here are sample addresses from input and ref, respectively (after preprocessing):

60651 N SPRINGFIELD AVE CHICAGO
60061 BROWNING CT VERNON HILLS

Here is what I have so far. (being a novice, I realize that there is probably all kinds of inefficiencies with my code, but that’s not the issue) :

import csv, re

f = csv.reader(open('/Users/benjaminbauman/Documents/inputsample.csv','rU'))

columns = zip(*f)

l = list(columns)

inputaddr = l[0][1:]

f = csv.reader(open('/Users/benjaminbauman/Documents/navstreets.csv','rU'))
f.next()

reffull = []
for row in f:
    row = str(row[0:7]).strip(r'['']').replace("\'","")
    if not ", , , , ," in row: reffull.append(row) 

input = list(set(inputaddr))

ref1 = list(set(reffull))
ref2 = ref1

input_scrub = []
for i in inputaddr:
    t = i.replace(',',' ')
    input_scrub.append(' '.join(t.split()))

ref_scrub = []

for i in ref1:
    t = i.replace(',',' ')
    ref_scrub.append(' '.join(t.split()))

output_iter1 = dict([ (i, [ r for r in ref_scrub if re.match(r, i) ]) for i in input_scrub ])

unmatched_iter1 = [i for i, j in output_iter1.items() if len(j) < 1]
matched_iter1 = {i: str(j[0][1]).strip(r'['']') for i, j in output_iter1.items() if len(j) is 1}
tied_iter1 = {k: zip(*(v))[1] for k,v in output_iter1.iteritems() if len(v) > 1}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:25:13+00:00Added an answer on June 18, 2026 at 12:25 pm

    Instead of fuzzy regex in the new module, maybe you could use the difflib module, if the execution time is acceptable:

    import difflib
    
    
    REF = ['455 Gateway Dr, Brooklyn, NY 11239',
           '10 Devoe St, Brooklyn, NY 11211',
           '8801 Queens Blvd, Elmhurst, NY 11373 ',
           '342 Wythe Ave, Brooklyn, NY 11249 ',
           '4488 E Live Oak Ave, Arcadia, CA 91006',
           '1134 N Vermont Ave, Los Angeles, CA 90029',
           '1101 17th St NW, Washington, DC 20036 ',
           '3001 Syringa St, Hopeful-City, AL 48798',
           '950 Laurel St, Minneapolis, KS 67467']
    
    
    INPUT = ['4554 Gagate Dr, Brooklyn, NY 11239',
             '10 Devoe St, Brooklyn, NY 11211',
             '8801 Queens Blvd, Elmhurst, NY 11373 ',
             '342 Wythe Ave, Brooklyn, NY 11249 ',
             '4488 E Live Oak Ave, Arcadia, CA 91006',
             '1134 N Vermont Ave, Los Angeles, CA 90029',
             '1101 17th St NW, Washington, DC 20036 ',
             '3001 Syrinuy St, Hopeful Dam, AL 48798',
             '950 Laurel St, Minneapolis, KS 67467',
             '455 Gateway Doctor, Forgotten Place, NY 11239',
             '10 Devoe St, Brook., NY 11211',
             '82477 Queens Blvd, Elmerst, NY 11373 ',
             '342 Waithe Street, Brooklyn, MN 11249 ',
             '4488 E Live Poke Ave, Arcadia, CA 145',
             '1134 N Vermiculite Ave, Liz Angelicas, CA 90029',
             '1101 1st St NW, Washing, DC 20036 ']
    
    
    def treatment(inp,reference,crit,gcm = difflib.get_close_matches):
        for input_item in inp:
            yield (input_item,gcm(input_item,reference,1000,crit))
    
    
    for a,b in treatment(INPUT,REF,0.65):
        print '\n- %s\n     %s' % (a, '\n     '.join(b))
    

    the result is:

    - 4554 Gagate Dr, Brooklyn, NY 11239
         455 Gateway Dr, Brooklyn, NY 11239
         342 Wythe Ave, Brooklyn, NY 11249 
    
    - 10 Devoe St, Brooklyn, NY 11211
         10 Devoe St, Brooklyn, NY 11211
    
    - 8801 Queens Blvd, Elmhurst, NY 11373 
         8801 Queens Blvd, Elmhurst, NY 11373 
    
    - 342 Wythe Ave, Brooklyn, NY 11249 
         342 Wythe Ave, Brooklyn, NY 11249 
         455 Gateway Dr, Brooklyn, NY 11239
    
    - 4488 E Live Oak Ave, Arcadia, CA 91006
         4488 E Live Oak Ave, Arcadia, CA 91006
    
    - 1134 N Vermont Ave, Los Angeles, CA 90029
         1134 N Vermont Ave, Los Angeles, CA 90029
    
    - 1101 17th St NW, Washington, DC 20036 
         1101 17th St NW, Washington, DC 20036 
    
    - 3001 Syrinuy St, Hopeful Dam, AL 48798
         3001 Syringa St, Hopeful-City, AL 48798
    
    - 950 Laurel St, Minneapolis, KS 67467
         950 Laurel St, Minneapolis, KS 67467
    
    - 455 Gateway Doctor, Forgotten Place, NY 11239
         455 Gateway Dr, Brooklyn, NY 11239
    
    - 10 Devoe St, Brook., NY 11211
         10 Devoe St, Brooklyn, NY 11211
    
    - 82477 Queens Blvd, Elmerst, NY 11373 
         8801 Queens Blvd, Elmhurst, NY 11373 
    
    - 342 Waithe Street, Brooklyn, MN 11249 
         342 Wythe Ave, Brooklyn, NY 11249 
         455 Gateway Dr, Brooklyn, NY 11239
    
    - 4488 E Live Poke Ave, Arcadia, CA 145
         4488 E Live Oak Ave, Arcadia, CA 91006
    
    - 1134 N Vermiculite Ave, Liz Angelicas, CA 90029
         1134 N Vermont Ave, Los Angeles, CA 90029
    
    - 1101 1st St NW, Washing, DC 20036 
         1101 17th St NW, Washington, DC 20036 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two CSV files which use @ to divide each column. The first
I have two csv file. First File has date offerid clicks orders Second File
I'm using XLWT to write excel files from .csv and I have the first
I have a PHP application that takes a CSV in input; in the first
I have a CSV file. The first row will always contain column headers. Depending
I'm currently just starting my first Lua program and I have a .csv file
I have a code where in I first convert a .csv file into multiple
I have CSV files that have multiple columns that are sorted. For instance, I
i have csv files, java app and database, i read csv file from my
I have some .csv files which I'm using as part of a test bench.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.