Exemple #1
0
def register_rating_2016():
    import pandas as pd
    for month in range(1,13):
        for day in range(1,32):
            csv_fn = "/Users/hinamiryouta/tmp/rating_csv_2016/16%02d%02d.csv" \
                    % (month, day)
            if not os.path.exists(csv_fn):
                continue
            df = pd.read_csv(csv_fn, skiprows=[0])
            day = "2016/%02d/%02d" % (month, day)
            Rating.insert_data(day, df)
            print(csv_fn)
Exemple #2
0
def tvdata_ajax(request): #{{{
    """ Viewer page """
    print(request.POST)
    date = request.POST.get("date")
    compare = request.POST.get("compare")
    station = request.POST.get("station")
    params = {'test':'test'}
    if compare is not None:
        params['epg']    = EPG.get_timetable_for_compare(date, station)
        params['rating'] = Rating.get_rating_by_station(date, station)
        return render_json_response(params)
    elif date:
        date_from = date + " 00:00:00"
        date_to = date + " 23:59:59"
        params['epg']    = EPG.get_timetable(date_from, date_to)
        params['rating'] = Rating.get_rating_by_time(date_from, date_to)
        return render_json_response(params)
    else:
        return render_json_response({'error':'error'})