31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import pandas as pd
|
|
import re
|
|
|
|
data = pd.read_excel("./【已确认】系统采集MT价格门店与商品清单 - 简版更新【机密】.xlsx").to_dict("records")
|
|
|
|
item_list = []
|
|
for i in data:
|
|
shop_name = i['门店名称']
|
|
city_name = i['城市']
|
|
coordinate_addr = i['地图定位地址']
|
|
shop_lat = str(i['门店纬度'])
|
|
shop_lng = str(i['门店经度'])
|
|
shop_lat_list = shop_lat.split('.')
|
|
shop_lat = shop_lat_list[0] + shop_lat_list[1]+'0'*(6-len(shop_lat_list[1]))
|
|
shop_lng_list = shop_lng.split('.')
|
|
shop_lng = shop_lng_list[0] + shop_lng_list[1]+'0'*(6-len(shop_lng_list[1]))
|
|
# 正则表达式拆分: Split by anything that is NOT (Chinese, English, or Numbers)
|
|
# Added 0-9 to keep numbers like '111' as part of the name
|
|
extracted_list = re.split(r'[^一-龥a-zA-Z0-9]+', str(shop_name))
|
|
name_part = extracted_list[0] if extracted_list else ""
|
|
|
|
item = {
|
|
'shop_name':shop_name,
|
|
'city_name':city_name,
|
|
'shop_lat':shop_lat,
|
|
'shop_lng':shop_lng,
|
|
'coordinate_addr':coordinate_addr,
|
|
'extracted_name': name_part
|
|
}
|
|
item_list.append(item)
|
|
pd.DataFrame(item_list).to_excel("./test.xlsx", index=False) |