mdbq 1.9.7__py3-none-any.whl → 1.9.9__py3-none-any.whl
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.
- mdbq/aggregation/aggregation.py +16 -8
- mdbq/aggregation/df_types.py +6 -0
- mdbq/clean/data_clean.py +13 -2
- {mdbq-1.9.7.dist-info → mdbq-1.9.9.dist-info}/METADATA +1 -1
- {mdbq-1.9.7.dist-info → mdbq-1.9.9.dist-info}/RECORD +7 -7
- {mdbq-1.9.7.dist-info → mdbq-1.9.9.dist-info}/WHEEL +1 -1
- {mdbq-1.9.7.dist-info → mdbq-1.9.9.dist-info}/top_level.txt +0 -0
mdbq/aggregation/aggregation.py
CHANGED
@@ -725,6 +725,9 @@ class DatabaseUpdate:
|
|
725
725
|
except Exception as e:
|
726
726
|
print(f'{name}, {e}')
|
727
727
|
if len(df) > 0:
|
728
|
+
if not db_name or not collection_name:
|
729
|
+
print(f'从本地csv文件中,根据文件标题匹配数据库名和数据表,结果存在空值,db_name: {db_name}, collection_name: {collection_name}')
|
730
|
+
# else:
|
728
731
|
# 将数据传入 self.datas 等待更新进数据库
|
729
732
|
self.datas.append(
|
730
733
|
{
|
@@ -763,14 +766,19 @@ class DatabaseUpdate:
|
|
763
766
|
# print(f'{name}/{sheet4} 跳过')
|
764
767
|
continue
|
765
768
|
df.insert(loc=1, column='报表类型', value=sheet4)
|
766
|
-
|
767
|
-
|
768
|
-
'
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
769
|
+
if not db_name or not collection_name:
|
770
|
+
print(
|
771
|
+
f'从本地csv文件中,根据文件标题匹配数据库名和数据表,结果存在空值,db_name: {db_name}, collection_name: {collection_name}')
|
772
|
+
else:
|
773
|
+
# 将数据传入 self.datas 等待更新进数据库
|
774
|
+
self.datas.append(
|
775
|
+
{
|
776
|
+
'数据库名': db_name,
|
777
|
+
'集合名称': collection_name,
|
778
|
+
'数据主体': df,
|
779
|
+
'文件名': name,
|
780
|
+
}
|
781
|
+
)
|
774
782
|
if is_move:
|
775
783
|
os.remove(os.path.join(root, name))
|
776
784
|
|
mdbq/aggregation/df_types.py
CHANGED
@@ -118,6 +118,12 @@ class DataTypes:
|
|
118
118
|
|
119
119
|
def as_json_file(self):
|
120
120
|
""" 保存为本地 json 文件 """
|
121
|
+
self.datas = {k: 'null' if v is None else v for k, v in self.datas.items()} # 替换字典中,值存在空值的值
|
122
|
+
self.datas = {k if k != None else 'null': v for k, v in self.datas.items()} # 替换字典中,键存在空值的键
|
123
|
+
if 'null' in str(self.datas):
|
124
|
+
print(f'self.datas 数据中存在空值,可能有未匹配的数据库名或数据表名,请检查 《标题对照表.csv》,已取消写入 df_types.json ')
|
125
|
+
print('self.datas: ', self.datas)
|
126
|
+
return
|
121
127
|
with open(self.json_file, 'w', encoding='utf-8_sig') as f:
|
122
128
|
json.dump(
|
123
129
|
self.datas,
|
mdbq/clean/data_clean.py
CHANGED
@@ -116,7 +116,15 @@ class DataClean:
|
|
116
116
|
|
117
117
|
df.replace(to_replace=['\\N'], value=0, regex=False, inplace=True) # 替换掉特殊字符
|
118
118
|
df.fillna(0, inplace=True)
|
119
|
-
col_ids = [
|
119
|
+
col_ids = [
|
120
|
+
# '场景ID', # 2024.10.5 改为不加 =""
|
121
|
+
'计划ID',
|
122
|
+
'单元ID',
|
123
|
+
'主体ID',
|
124
|
+
'宝贝ID',
|
125
|
+
'词ID/词包ID',
|
126
|
+
'创意ID',
|
127
|
+
]
|
120
128
|
sb = df.columns.tolist()
|
121
129
|
if '日期' not in sb:
|
122
130
|
print(f'{name} 注意:该报表不包含分日数据,数据不会保存,请重新下载!')
|
@@ -162,7 +170,10 @@ class DataClean:
|
|
162
170
|
shop_name = shop_name[0]
|
163
171
|
else:
|
164
172
|
shop_name = ''
|
165
|
-
cols = [
|
173
|
+
cols = [
|
174
|
+
# '场景ID', # 2024.10.5 改为不加 =""
|
175
|
+
'计划ID',
|
176
|
+
]
|
166
177
|
for col in cols:
|
167
178
|
df[col] = df[col].apply(lambda x: f'="{x}"' if x and '=' not in str(x) else x)
|
168
179
|
df.replace(to_replace=['\\N'], value=0, regex=False, inplace=True) # 替换掉特殊字符
|
@@ -1,15 +1,15 @@
|
|
1
1
|
mdbq/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
|
2
2
|
mdbq/__version__.py,sha256=y9Mp_8x0BCZSHsdLT_q5tX9wZwd5QgqrSIENLrb6vXA,62
|
3
3
|
mdbq/aggregation/__init__.py,sha256=EeDqX2Aml6SPx8363J-v1lz0EcZtgwIBYyCJV6CcEDU,40
|
4
|
-
mdbq/aggregation/aggregation.py,sha256=
|
5
|
-
mdbq/aggregation/df_types.py,sha256=
|
4
|
+
mdbq/aggregation/aggregation.py,sha256=ZDMYHZXuVx9MIiTYDjGUHLNBvj98h6-q6x2BrlBdaNw,72786
|
5
|
+
mdbq/aggregation/df_types.py,sha256=U9i3q2eRPTDY8qAPTw7irzu-Tlg4CIySW9uYro81wdk,8125
|
6
6
|
mdbq/aggregation/mysql_types.py,sha256=DQYROALDiwjJzjhaJfIIdnsrNs11i5BORlj_v6bp67Y,11062
|
7
7
|
mdbq/aggregation/optimize_data.py,sha256=u2Kl_MFtZueXJ57ycy4H2OhXD431RctUYJYCl637uT0,4176
|
8
8
|
mdbq/aggregation/query_data.py,sha256=32NjVVYLnfFkzD8TflmNVhpdQTLRRUrb9toMGApSOC8,72379
|
9
9
|
mdbq/bdup/__init__.py,sha256=AkhsGk81SkG1c8FqDH5tRq-8MZmFobVbN60DTyukYTY,28
|
10
10
|
mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
|
11
11
|
mdbq/clean/__init__.py,sha256=A1d6x3L27j4NtLgiFV5TANwEkLuaDfPHDQNrPBbNWtU,41
|
12
|
-
mdbq/clean/data_clean.py,sha256=
|
12
|
+
mdbq/clean/data_clean.py,sha256=BgOZlJwuv5X4BL24DOHC6XtMFspFD-AdCBC_EJJ9rjA,101382
|
13
13
|
mdbq/company/__init__.py,sha256=qz8F_GsP_pMB5PblgJAUAMjasuZbOEp3qQOCB39E8f0,21
|
14
14
|
mdbq/company/copysh.py,sha256=VUaaJPXPYPHWwnkdK77PWz_dAXZyEmYBA9Df1yROHAc,17764
|
15
15
|
mdbq/config/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
@@ -36,7 +36,7 @@ mdbq/pbix/__init__.py,sha256=Trtfaynu9RjoTyLLYBN2xdRxTvm_zhCniUkVTAYwcjo,24
|
|
36
36
|
mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,2396
|
37
37
|
mdbq/pbix/refresh_all.py,sha256=0uAnBKCd5cx5FLTkawN1GV9yi87rfyMgYal5LABtumQ,7186
|
38
38
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
39
|
-
mdbq-1.9.
|
40
|
-
mdbq-1.9.
|
41
|
-
mdbq-1.9.
|
42
|
-
mdbq-1.9.
|
39
|
+
mdbq-1.9.9.dist-info/METADATA,sha256=zYBl4BSGNMyJDZRf5BKpMZKIxlJv6tPosWHyZlc7w04,245
|
40
|
+
mdbq-1.9.9.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
41
|
+
mdbq-1.9.9.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
42
|
+
mdbq-1.9.9.dist-info/RECORD,,
|
File without changes
|