codefornola / address-autocomplete

A tool to autocomplete valid New Orleans addresses in html forms
MIT License
0 stars 3 forks source link

download addresses and create unique list #2

Closed mrcnc closed 7 years ago

mrcnc commented 7 years ago

Use the list here https://data.nola.gov/Geographic-Base-Layers/Addresses/s4ns-ak5d

mrcnc commented 7 years ago

wget -O addresses.csv https://opendata.arcgis.com/datasets/b7956c8840554a25ae4e35d08b8c17a6_0.csv

mrcnc commented 7 years ago

Here's a python snippet to get the list of addresses into a JS array:

import csv
csvfile = open('addresses.csv')
reader = csv.DictReader(csvfile)
addresses = [row['FULLADDR'].upper() for row in reader]
with open('addresses.js', 'w') as output:
    output.write('var addresses = ')
    output.write(str(addresses))
    output.write(';')
mrcnc commented 7 years ago

Initial work started here. Still a lot of things to do...just updating here in case anyone is interested

aaron-junot commented 7 years ago

Cool, I haven't ran the code but I have looked at it. Can I fix the thing about var _this = this; using bind() or call() depending on what's easy and still readable?

mrcnc commented 7 years ago

@aaron-suarez...sure...if you can get this working before I get around to it, submit a PR

aaron-junot commented 7 years ago

@mrcnc My proposal is the following. Since you haven't committed to codefornola/address-autocomplete, am I expected to do a PR to your fork? Please advise, and I'll do the PR. I just tested it with console.log and it gave me the behavior I expected. Let me know which version you'd like me to use as well. If you go with version 2, please let me know what to name this function, as I'm not entirely sure that "traverse" is even what this function is doing...

Version 1:

Object.keys(node.children).forEach(function(key) {
      this.dfs(node.children[key], sofar.concat(key), words);
}.bind(this));

Version 2:

function traverse (key) {
      this.dfs(node.children[key], sofar.concat(key), words);
}

Object.keys(node.children).forEach(traverse.bind(this));
mrcnc commented 7 years ago

I'll call this one completed from #3