mdbq 1.7.5__tar.gz → 1.7.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {mdbq-1.7.5 → mdbq-1.7.7}/PKG-INFO +1 -1
  2. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/aggregation.py +26 -8
  3. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/clean/data_clean.py +24 -0
  4. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/company/copysh.py +9 -0
  5. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/pbix/refresh_all.py +28 -3
  6. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq.egg-info/PKG-INFO +1 -1
  7. {mdbq-1.7.5 → mdbq-1.7.7}/setup.py +1 -1
  8. {mdbq-1.7.5 → mdbq-1.7.7}/README.txt +0 -0
  9. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/__init__.py +0 -0
  10. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/__version__.py +0 -0
  11. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/__init__.py +0 -0
  12. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/df_types.py +0 -0
  13. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/mysql_types.py +0 -0
  14. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/optimize_data.py +0 -0
  15. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/aggregation/query_data.py +0 -0
  16. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/bdup/__init__.py +0 -0
  17. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/bdup/bdup.py +0 -0
  18. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/clean/__init__.py +0 -0
  19. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/company/__init__.py +0 -0
  20. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/config/__init__.py +0 -0
  21. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/config/get_myconf.py +0 -0
  22. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/config/products.py +0 -0
  23. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/config/set_support.py +0 -0
  24. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/config/update_conf.py +0 -0
  25. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/dataframe/__init__.py +0 -0
  26. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/dataframe/converter.py +0 -0
  27. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/log/__init__.py +0 -0
  28. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/log/mylogger.py +0 -0
  29. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mongo/__init__.py +0 -0
  30. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mongo/mongo.py +0 -0
  31. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mysql/__init__.py +0 -0
  32. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mysql/mysql.py +0 -0
  33. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mysql/s_query.py +0 -0
  34. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/mysql/year_month_day.py +0 -0
  35. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/other/__init__.py +0 -0
  36. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/other/porxy.py +0 -0
  37. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/other/pov_city.py +0 -0
  38. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/other/ua_sj.py +0 -0
  39. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/pbix/__init__.py +0 -0
  40. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/pbix/pbix_refresh.py +0 -0
  41. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq/spider/__init__.py +0 -0
  42. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq.egg-info/SOURCES.txt +0 -0
  43. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq.egg-info/dependency_links.txt +0 -0
  44. {mdbq-1.7.5 → mdbq-1.7.7}/mdbq.egg-info/top_level.txt +0 -0
  45. {mdbq-1.7.5 → mdbq-1.7.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.7.5
3
+ Version: 1.7.7
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -189,6 +189,24 @@ class DatabaseUpdate:
189
189
  collection_name='店铺来源_日数据_旧版'
190
190
  elif name.endswith('.csv') and '客户运营平台_客户列表' in name:
191
191
  df = pd.read_csv(os.path.join(root, name), encoding=encoding, header=0, na_filter=False)
192
+ elif name.endswith('.xls') and '生意参谋' in name and '无线店铺三级流量来源详情' in name:
193
+ # 店铺来源,手淘搜索,关键词
194
+ pattern = re.findall(r'(\d{4}-\d{2}-\d{2})_(\d{4}-\d{2}-\d{2})', name)
195
+ df = pd.read_excel(os.path.join(root, name), header=5)
196
+ if len(df) == 0:
197
+ print(f'{name} 报表数据为空')
198
+ continue
199
+ df.replace(to_replace=[','], value='', regex=True, inplace=True)
200
+ df.insert(loc=0, column='日期', value=pattern[0][1])
201
+ df.rename(columns={
202
+ '来源名称': '关键词',
203
+ '收藏商品-支付买家数': '收藏商品_支付买家数',
204
+ '加购商品-支付买家数': '加购商品_支付买家数',
205
+ }, inplace=True)
206
+ if pattern[0][0] != pattern[0][1]:
207
+ data_lis = pattern[0][0] + '_' + pattern[0][1]
208
+ df.insert(loc=1, column='数据周期', value=data_lis)
209
+
192
210
  elif name.endswith('.xls') and '生意参谋' in name and '商品_全部' in name:
193
211
  # 店铺商品排行
194
212
  df = pd.read_excel(os.path.join(root, name), header=4)
@@ -1082,12 +1100,12 @@ if __name__ == '__main__':
1082
1100
  # database='mysql'
1083
1101
  # )
1084
1102
 
1085
- db_name = '推广数据2'
1086
- table_name = '超级直播'
1087
- upload_dir(
1088
- path='/Users/xigua/数据中心/原始文件2/推广报表/超级直播',
1089
- db_name=db_name,
1090
- collection_name=table_name,
1091
- dbs={'mysql': True, 'mongodb': False},
1092
- )
1103
+ # db_name = '推广数据2'
1104
+ # table_name = '超级直播'
1105
+ # upload_dir(
1106
+ # path='/Users/xigua/数据中心/原始文件2/推广报表/超级直播',
1107
+ # db_name=db_name,
1108
+ # collection_name=table_name,
1109
+ # dbs={'mysql': True, 'mongodb': False},
1110
+ # )
1093
1111
 
@@ -298,6 +298,27 @@ class DataClean:
298
298
  m.df_to_mysql(df=df, db_name='生意参谋2', tabel_name='生意参谋_店铺来源_日数据_旧版')
299
299
  os.remove(os.path.join(root, name))
300
300
 
301
+ elif name.endswith('.xls') and '生意参谋' in name and '无线店铺三级流量来源详情' in name:
302
+ # 店铺来源,手淘搜索,关键词
303
+ pattern = re.findall(r'(\d{4}-\d{2}-\d{2})_(\d{4}-\d{2}-\d{2})', name)
304
+ df = pd.read_excel(os.path.join(root, name), header=5)
305
+ if len(df) == 0:
306
+ print(f'{name} 报表数据为空')
307
+ continue
308
+ df.replace(to_replace=[','], value='', regex=True, inplace=True)
309
+ df.insert(loc=0, column='日期', value=pattern[0][1])
310
+ df.rename(columns={
311
+ '来源名称': '关键词',
312
+ '收藏商品-支付买家数': '收藏商品_支付买家数',
313
+ '加购商品-支付买家数': '加购商品_支付买家数',
314
+ }, inplace=True)
315
+ if pattern[0][0] != pattern[0][1]:
316
+ data_lis = pattern[0][0] + '_' + pattern[0][1]
317
+ df.insert(loc=1, column='数据周期', value=data_lis)
318
+ new_name = os.path.splitext(name)[0] + '.csv'
319
+ self.save_to_csv(df, root, new_name) # mysql 可能改变 df 列名,所以在上传 mysql 前保存 csv
320
+ os.remove(os.path.join(root, name))
321
+
301
322
  elif name.endswith('.xls') and '生意参谋' in name and '商品_全部' in name:
302
323
  # 店铺商品排行
303
324
  new_name = os.path.splitext(name)[0] + '.csv'
@@ -1055,6 +1076,9 @@ class DataClean:
1055
1076
  else:
1056
1077
  t_path = str(pathlib.Path(self.source_path, '生意参谋/流量来源_旧版'))
1057
1078
  bib(t_path, _as_month=True)
1079
+ elif name.endswith('.csv') and '生意参谋' in name and '无线店铺三级流量来源详情' in name:
1080
+ t_path = str(pathlib.Path(self.source_path, '生意参谋/手淘搜索来源'))
1081
+ bib(t_path, _as_month=True)
1058
1082
  elif name.endswith('.csv') and '商品_全部' in name:
1059
1083
  t_path = str(pathlib.Path(self.source_path, '生意参谋/商品排行'))
1060
1084
  bib(t_path, _as_month=True)
@@ -250,6 +250,15 @@ class TbFiles:
250
250
  else:
251
251
  print(f'{src} 所需同步的文件不存在,请检查:pd_list参数')
252
252
 
253
+ excel_path = os.path.join(self.share_path, 'EXCEL报表')
254
+ files = os.listdir(excel_path)
255
+ for file in files:
256
+ if file.endswith('.xlsx'):
257
+ now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
258
+ print(f'正在刷新 excel: {file}')
259
+ r.refresh_excel2(excel_file=os.path.join(excel_path, file))
260
+ time.sleep(10)
261
+
253
262
  self.before_max_time = self.check_change() # 重置值, 避免重复同步
254
263
 
255
264
  now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
@@ -17,7 +17,7 @@ class RefreshAll:
17
17
  def __init__(self):
18
18
  self.my_conf = os.path.join(set_support.SetSupport(dirname='support').dirname, '.my_conf')
19
19
  self.pbix_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'ref_list.txt')
20
- self.excel_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'cp_list.txt')
20
+ self.excel_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'ref_list.txt')
21
21
  self.run_py_path = 'run_py'
22
22
  self.procname = 'PBIDesktop.exe'
23
23
 
@@ -84,6 +84,31 @@ class RefreshAll:
84
84
  except Exception as e:
85
85
  print(e)
86
86
 
87
+ def refresh_excel2(self, excel_file):
88
+ # 刷新 excel
89
+ if excel_file.endswith('.xlsx'):
90
+ try:
91
+ print(f'正在刷新 >>>{excel_file}')
92
+ xlapp = win32com.client.Dispatch('Excel.Application') # 创建Excel程序App
93
+ xlapp.Visible = False # 窗口是否可见
94
+ xlapp.DisplayAlerts = False # 是否显示警告信息
95
+ wb = xlapp.Workbooks.Open(excel_file)
96
+ conjuncts = wb.Connections.Count # 统计工作簿含有多少外部链接
97
+ if conjuncts == 0:
98
+ wb.Close(SaveChanges=False)
99
+ xlapp.Quit()
100
+ else:
101
+ time.sleep(2)
102
+ wb.RefreshAll()
103
+ xlapp.CalculateUntilAsyncQueriesDone()
104
+ time.sleep(2)
105
+ wb.Save()
106
+ wb.Close(SaveChanges=True)
107
+ xlapp.Quit()
108
+ print('文件刷新 >>>' + excel_file)
109
+ except Exception as e:
110
+ print(e)
111
+
87
112
  def pbi(self, path, _timeout=300):
88
113
  """
89
114
  这是原本属于独立的库模块: pbix_refresh
@@ -146,7 +171,7 @@ class RefreshAll:
146
171
 
147
172
 
148
173
  if __name__ == '__main__':
149
- # r = RefreshAll()
174
+ r = RefreshAll()
150
175
  # r.refresh_pbix()
151
- # r.refresh_excel()
176
+ r.refresh_excel()
152
177
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.7.5
3
+ Version: 1.7.7
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -3,7 +3,7 @@
3
3
  from setuptools import setup, find_packages
4
4
 
5
5
  setup(name='mdbq',
6
- version='1.7.5',
6
+ version='1.7.7',
7
7
  author='xigua, ',
8
8
  author_email="2587125111@qq.com",
9
9
  url='https://pypi.org/project/mdbsql',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes