Пример #1
0
 def save_statistics_as_csv(self):
     statistic_csv_handler = CsvHandler(
         filepath = self.csv_ttest_path,
         header_list = self.t_stat_header_list
     )
     statistic_csv_handler.dict_to_csv(
         dict_list = self.statistic_dict_list
     )
Пример #2
0
 def save_record_info_as_csv(self):
     info_csv_handler = CsvHandler(
         filepath = self.csv_info_path,
         header_list = self.level_info_header_list
     )
     info_csv_handler.dict_to_csv(
         dict_list = self.level_info_dict_list
     )
Пример #3
0
csv_handler = CsvHandler(filepath=options.drag_file, header_list=header_list)

#f = open(options.json_file, 'w')
date_list_json = rest_handler.get_json_of_date_list()
date_list = json_handler.json_to_date_list(date_list_json)
for idx, date in enumerate(date_list):
    #for idx, date in enumerate(['1970-01-01','2019-02-07']):
    #result_dict_list = []
    if date == '1970/01/01':
        print('Date 1970/01/01')
        continue
    print('[{}], ({}/{}) Now Collecting'.format(date, idx + 1, len(date_list)))
    for mobile_os in ('iOS', 'Android'):
        person_list_json = rest_handler.get_json_of_person_id_by_date(
            date, mobile_os)
        person_list = json_handler.json_to_person_list(person_list_json,
                                                       mobile_os)
        print('\t{}, User : {}'.format(mobile_os, len(person_list)))
        if len(person_list) == 0:
            print('\tNo Person.')
            continue
        for person_id in person_list:
            drag_data_json = rest_handler.get_json_by_date_and_person_id(
                date, person_id, mobile_os)
            temp_dict_list = json_handler.json_to_dict_list(
                json_source=drag_data_json, person_id=person_id)
            #result_dict_list += temp_dict_list
            csv_handler.dict_to_csv(temp_dict_list)
    #del result_dict_list
    #print(process.memory_info().rss)  # in bytes
    #gc.collect()
Пример #4
0
sys.path.append('{}/ProjectDoBrain/codes/Modules'.format(home))
from rest_handler import RestHandler
from json_handler import JsonHandler
from csv_handler import CsvHandler


def parse_commands(argv):
    from optparse import OptionParser
    parser = OptionParser('"')
    parser.add_option('-s', '--surveyFile', dest='survey_file')
    parser.add_option('-b', '--birthdayFile', dest='birthday_file')
    parser.add_option('-m', '--mobileOS', dest='mobile_os')
    options, otherjunk = parser.parse_args(argv)
    return options


options = parse_commands(sys.argv[1:])

header_list = ['person_id', 'birthday']
survey_df = pd.read_csv(options.survey_file)

rest_handler = RestHandler(mobile_os=options.mobile_os)
json_handler = JsonHandler()
csv_handler = CsvHandler(filepath=options.birthday_file,
                         header_list=header_list)

for person in survey_df.person_id.unique():
    json_result = rest_handler.get_user_data_by_person_id(person)
    result_dict_list = json_handler.user_json_to_birthday(person, json_result)
    csv_handler.dict_to_csv(dict_list=result_dict_list)