示例#1
0
tweets_file = "/home/clemsos/Dev/mitras/results/" + meme_name + "/" + meme_name + ".csv"

#tweets_file="/home/clemsos/Dev/mitras/lib/cities/usersample.csv"

# get user data
api = UserAPI()
user_provinces = []
with open(tweets_file, 'rb') as csvfile:

    weibo_data = csv.reader(csvfile)
    csvfile.next()  #skip csv header
    print "processing tweets..."
    for tweet in weibo_data:
        # print tweet[0]
        province_code = api.get_province(tweet[0])
        # print province_code
        try:
            user_provinces.append(api.provinces[province_code])
        except KeyError:
            print "error"

# print province_count
province_count = [(p[0], p[1] / 100)
                  for p in Counter(user_provinces).most_common()]

# create HTML file with map
html_template = "/home/clemsos/Dev/mitras/d3-china-map/map_template.html"

out_dir = "/home/clemsos/Dev/mitras/results"
out_filename = out_dir + "/map_user" + meme_name + ".html"
示例#2
0
# -*- coding: utf-8 -*-

'''
This is a test for user db interactions
'''
import csv
from collections import Counter

from test_helpers import TestHelpers
helpers=TestHelpers()
helpers.add_relative_path()

from lib.users import UserAPI

api=UserAPI()
result = api.get_province("uHRWEYSX0")
print result


userdata_file="/home/clemsos/Dev/mitras/lib/cities/usersample.csv"
def test_write_users(userdata_file): 

    with open(userdata_file, 'rb') as csvfile:
        i=0

        user_data=csv.reader(csvfile)
        csvfile.next() #skip csv header
        
        for row in user_data:
            api.create_user(row)
            i+=1
示例#3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This is a test for user db interactions
'''
import csv
from collections import Counter

from test_helpers import TestHelpers
helpers = TestHelpers()
helpers.add_relative_path()

from lib.users import UserAPI

api = UserAPI()
result = api.get_province("uHRWEYSX0")
print result

userdata_file = "/home/clemsos/Dev/mitras/lib/cities/usersample.csv"


def test_write_users(userdata_file):

    with open(userdata_file, 'rb') as csvfile:
        i = 0

        user_data = csv.reader(csvfile)
        csvfile.next()  #skip csv header

        for row in user_data:
            api.create_user(row)