帮助建立关系,建立API并解决下面的编码挑战! [英] Help in establishing relationships, buiding API and solving coding challenge below!!!

查看:74
本文介绍了帮助建立关系,建立API并解决下面的编码挑战!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本练习的目的是结合示例数据库,点击测试网站和应用程序的跟踪信息,以及来自用户社交网络的信息。



示例数据库包含以下字段,由500条记录组成。



first_name,last_name,company_name,地址,城市,县,州, zip,phone1,phone2,email,web



以下是说明:



1)下载US500数据库来自http://www.briandunning.com/sample-data/



2)使用电话号码的交换部分(中间三位数) 用户点击并表达了对此主题的兴趣的代理。识别共享主题兴趣的用户组(交换号码匹配)。



3)提供一个API,将电子邮件地址作为输入,并返回e-共享该兴趣的其他用户的邮件地址。



4)扩展该API以返回该兴趣的某个距离N内的用户。例如,如果原始用户对组236感兴趣,并且N为2,则返回所有在234到238中感兴趣的用户。



5)识别和排名具有最大组的州和(单独)最大数量的组。



6)提供API工作的一个或多个演示。这些可以通过测试框架,和/或快速和脏的Web或命令行客户端,或者只是通过从浏览器驱动它并显示原始结果。





我能够以这种方式导入数据,但是我知道使用CSV模块有更好的方法。下面的代码只是读取行,我希望能够将每个单独的字段拆分成列并分配主键和外键以解决挑战。完成这项任务的最佳方法是什么?



import os,csv,json,re



class fetch500():#class instantiation

def __init __(self):#initializes data import object

US_500file = open('us-500.csv')

us_500list = US_500file.readlines()

for us_500list中的列:

print column,#print out phone1 array



data_import = fetch500()

print fetch500()

The aim of this exercise is to combine the sample database, click tracking information from a test website and application, and information from user's social networks.

The sample database contains the following fields and is made up of 500 records.

first_name, last_name, company_name, address, city, county, state, zip, phone1, phone2, email, web

Here are the instructions:

1) Download the US500 database from http://www.briandunning.com/sample-data/

2) Use the exchange portion of the telephone numbers (the middle three digits) as the proxy for "user clicked on and expressed interest in this topic". Identify groups of users that share topic interests (exchange numbers match).

3) Provide an API that takes an e-mail address an input, and returns the e-mail addresses of other users that share that interest.

4) Extend that API to return users within a certain "distance" N of that interest. For example, if the original user has an interest in group 236, and N is 2, return all users with interests in 234 through 238.

5) Identify and rank the states with the largest groups, and (separately) the largest number of groups.

6) Provide one or more demonstrations that the API works. These can be via a testing framework, and/or a quick and dirty web or command line client, or simply by driving it from a browser and showing a raw result.


I was able to import the data this way, however I know there's a better method using the CSV module. The code below just reads lines, I'd like to be able to split each individual field into columns and assign primary and foreign keys in order to solve the challenge. What's the best method to accomplish this task?

import os, csv, json, re

class fetch500(): # class instantiation
def __init__(self): # initializes data import object
US_500file = open('us-500.csv')
us_500list = US_500file.readlines()
for column in us_500list:
print column, # prints out phone1 array

data_import = fetch500()
print fetch500()

推荐答案

我的挑战是尽快获得积分报告像这样的问题;)



为什么?

不需要你的支持。
My challenge is to get asap enough Points to report questions like this ;)

Why?
No effort from your side.


这篇关于帮助建立关系,建立API并解决下面的编码挑战!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆