Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

python对于excel数据按照标签进行分组处理

最近做的利用百度api对路线进行路径纠偏,由于本人实在小白遇到很多问题。
数据是这样的,其中imsi有八十个不同的。
image.png
image.png
对于路线纠偏的代码如下

import requests
url = "http://api.map.baidu.com/rectify/v1/track? //POST请求"

payload = {'ak': 'GbYuGBxS0wBbNo7lmf4H8A51CPikHXaX',
'point_list':
  '[{"coord_type_input":"bd09ll","loc_time":"1538469875","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538559097","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538559169","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538559200","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538560137","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538561315","latitude":"41.51470947","longitude":"122.8896332"},    {"coord_type_input":"bd09ll","loc_time":"1538561316","latitude":"41.51470947","longitude":"122.8896332"},    {"coord_type_input":"bd09ll","loc_time":"1538561798","latitude":"41.51470947","longitude":"122.8896332"},    {"coord_type_input":"bd09ll","loc_time":"1538561873","latitude":"41.51470947","longitude":"122.8896332"},    {"coord_type_input":"bd09ll","loc_time":"1538563008","latitude":"41.52077866","longitude":"122.9067917"},    {"coord_type_input":"bd09ll","loc_time":"1538565120","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538565308","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538566778","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538566796","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538567459","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538567647","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538568629","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538568718","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538569911","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538570363","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538570436","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538570526","latitude":"41.51839828","longitude":"122.8960876"},    {"coord_type_input":"bd09ll","loc_time":"1538571787","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538571908","latitude":"41.51762009","longitude":"122.8947372"},    {"coord_type_input":"bd09ll","loc_time":"1538576650","latitude":"41.79916","longitude":"123.40065"},    {"coord_type_input":"bd09ll","loc_time":"1538578125","latitude":"41.8078804","longitude":"123.4119873"},    {"coord_type_input":"bd09ll","loc_time":"1538578725","latitude":"41.8078804","longitude":"123.4119873"},    {"coord_type_input":"bd09ll","loc_time":"1538578740","latitude":"41.8078804","longitude":"123.4119873"},    {"coord_type_input":"bd09ll","loc_time":"1538579250","latitude":"41.8078804","longitude":"123.4119873"},    {"coord_type_input":"bd09ll","loc_time":"1538580687","latitude":"41.8078804","longitude":"123.4119873"},    {"coord_type_input":"bd09ll","loc_time":"1538582003","latitude":"41.80886078","longitude":"123.4087296"},    {"coord_type_input":"bd09ll","loc_time":"1538582146","latitude":"41.80886078","longitude":"123.4087296"},    {"coord_type_input":"bd09ll","loc_time":"1538508443","latitude":"41.51470947","longitude":"122.8896332"}]',
'rectify_option': 'need_mapmatch:1|transport_mode:auto|denoise_grade:2|vacuate_grade:1',
'supplement_mode': 'no_supplement',
'coord_type_output': 'bd09ll',
'extensions': 'base'}
files = [

]
headers = {
  'Cookie': 'BAIDUID=3BD05070EA56816BB6FF7B088D3FC630:FG=1'
}

response = requests.request("POST", url, headers=headers, data = payload, files = files)

print(response.text.encode('utf8'))
new=open(r'A.txt','a')
new.write(response.text)

new.close()

但是这个只能将坐标点输入进去(而且百度api的要求是数据点不能过多),如果重复八十次实在是浪费人力,而且后期数据更多的时候更加无法操作。有没有方法能依次对不同的imsi用户进行以上操作,感觉还是有点复杂。

或者能不能将数据按照imsi输出成这样:
image.png

这样我一个一个输入也会方便一些,泪目


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...