while r.next()[0] != 'Total New Zealand': pass # skip over regions """# CMBs for line in r: if line[0] == 'Total Auckland Local Board': break if line[0][9] != ' ': print(line) assert False census_names.add(line[0][10:])""" regions = trademe.get_localities() trademe_names = set(district['Name'] for region in regions for district in region['Districts']) mapped_tmnames = set() mapped_csnames = set() with open('WhereToLive/censusdata/name-map.txt', 'r') as f: for line in f: tmname, csname = line.replace('\n','').split(',') if tmname not in trademe_names: print('not valid: TM'+tmname) else: mapped_tmnames.add(tmname) if csname not in census_names: print('not valid: CS'+csname) else:
from django.http import HttpResponse from django.shortcuts import render_to_response import json import trademe locality_data = trademe.get_localities() all_places = trademe.get_place_list() with open('WhereToLive/censusdata/summarydata.json', 'r') as f: census_summary_data = json.load(f) def home(request): ctx = {} ctx['job_categories'] = trademe.get_job_categories() return render_to_response('static/index.html', ctx) def do_search(search_job_category): job_count_by_place = {} for job in trademe.get_all_jobs(): if job['Category'][0:len(search_job_category)] == search_job_category: place = job['Place'] if place not in job_count_by_place: job_count_by_place[place] = 0 job_count_by_place[place] += 1 return sorted(job_count_by_place.keys(), key=lambda place: -job_count_by_place[place]), job_count_by_place def ajax_search(request): best_places, job_count_by_place = do_search(request.GET["industry"]) response = {"best_places":[{"name": place, "jobcount": job_count_by_place[place]} for place in best_places[:3]]} return HttpResponse(json.dumps(response))