Beispiel #1
0
def _preprocess_fitfile(file_path):
    ff = FitFile(file_path)
    data = []
    key_mapping = {
        "position_lat": "Latitude",
        "position_long": "Longitude",
        "heart_rate": "Heading",
        "enhanced_speed": "Speed",
        "timestamp": "Gentime"
    }
    for record in ff.get_messages('record'):
        record_dict = {
            metric.name:
            (metric.value if metric.name != "timestamp" else metric.raw_value)
            for metric in record
        }
        if all(required_key in record_dict.keys()
               for required_key in key_mapping):
            record_dict.update({
                'activityId':
                7,
                'type':
                'fitfile_upload',
                "position_lat":
                semicircles_to_degrees(record_dict["position_lat"]),
                "position_long":
                semicircles_to_degrees(record_dict["position_long"])
            })
            data.append(record_dict)
        else:
            print("skipping")
    return data, key_mapping
def get_data(f_name):
    data = []
    cont = csv.reader(open(f_name, "rb"))
    next(cont, None)
    for i in cont:
        data.append(i)
    return data
Beispiel #3
0
 def filecsv(self, value1, value2):
     csvs = open('d:\\python\\text.csv', 'r')
     reader = csv.reader(csvs)
     data = []
     for row in reader:
         data.append(row)
     csvs.close()
     print(data[value1][value2])
     return data[value1][value2]
Beispiel #4
0
def csvRead():
    data = []
    counter = 0
    with open('testdata.csv', newline='') as csvfile:
        dataReader = csv.reader(csvfile, delimiter=',')
        for row in dataReader:
            if counter == 0:
                pass
            else:
                data.append((f'{row[0]}', int(row[1])))
            counter += 1
    return data
Beispiel #5
0
 def test_view_news(self):
     #获取新闻列表分页
     data = []
     page = getCsv(12, 1, self.file_name)
     pagesize = getCsv(13, 1, self.file_name)
     activityid = getCsv(14, 1, self.file_name)
     userid = getCsv(15, 1, self.file_name)
     data.append(page)
     data.append(pagesize)
     data.append(activityid)
     data.append(userid)
     url = self.base_url + "/v1/admin/news/view-news"
     ac = self.news.view_news(url, data)
     self.assertEqual(ac, 200)
def read_file():
    data = []
    with open("params.txt", "r", encoding="utf-8") as f:
        for line in f.readlines():
            data.append(line.strip("\n").split(","))
    return data
Beispiel #7
0
def get_data(f_name):
    data = []
    cont = xlrd.open_workbook(f_name).sheet_by_index(0)
    for i in range(1, cont.nrows):
        data.append(list(cont.row_values(i, 0, cont.ncols)))
    return data
Beispiel #8
0
 def test_modify_news(self):
     #修改新闻
     data = []
     data.append(getCsv(0, 1, self.file_name))
     data.append(getCsv(1, 1, self.file_name))
     data.append(getCsv(2, 1, self.file_name))
     data.append(getCsv(3, 1, self.file_name))
     data.append(getCsv(4, 1, self.file_name))
     data.append(getCsv(5, 1, self.file_name))
     data.append(getCsv(6, 1, self.file_name))
     data.append(getCsv(7, 1, self.file_name))
     data.append(getCsv(8, 1, self.file_name))
     data.append(getCsv(9, 1, self.file_name))
     data.append(getCsv(10, 1, self.file_name))
     data.append(getCsv(8, 1, self.file_name))
     data.append(getCsv(11, 1, self.file_name))
     url = self.base_url + "/v1/admin/news/modify-news"
     ac = self.news.modify_news(url, data)
     self.assertEqual(ac, 200)
Beispiel #9
0
 def test_add_news(self):
     #新增新闻
     data = []
     data.append(getCsv(0, 1, self.file_name))
     data.append(getCsv(1, 1, self.file_name))
     data.append(getCsv(2, 1, self.file_name))
     data.append(getCsv(3, 1, self.file_name))
     data.append(getCsv(4, 1, self.file_name))
     data.append(getCsv(5, 1, self.file_name))
     data.append(getCsv(6, 1, self.file_name))
     data.append(getCsv(7, 1, self.file_name))
     data.append(getCsv(9, 1, self.file_name))
     data.append(getCsv(10, 1, self.file_name))
     url = self.base_url + "/v1/admin/news/news-add"
     ac = self.news.add_news(url, data)
     self.assertEqual(ac, 200)