Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
重
重点类信息提取
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZGC_INDEX
重点类信息提取
Commits
1241ae1d
Commit
1241ae1d
authored
Apr 25, 2021
by
Jialin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码更新
parent
46cdf40a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
重复产品更新.py
公共代码/重复产品更新.py
+12
-5
No files found.
公共代码/重复产品更新.py
View file @
1241ae1d
...
@@ -13,7 +13,7 @@ import os
...
@@ -13,7 +13,7 @@ import os
def
duplicate_product_update
(
filepath
,
sheet_name
=
0
):
def
duplicate_product_update
(
filepath
,
sheet_name
=
0
):
df
=
pd
.
read_excel
(
filepath
,
sheet_name
=
sheet_name
,
converters
=
{
'产品编码'
:
str
})
df
=
pd
.
read_excel
(
filepath
,
sheet_name
=
sheet_name
,
converters
=
{
'产品编码'
:
str
,
'正确产品编码'
:
str
,
'产品名称'
:
str
,
'正确产品名称'
:
str
})
conn_zi_new
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'zgcprice20200628'
,
database
=
'ZI_NEW'
,
autocommit
=
True
)
conn_zi_new
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'zgcprice20200628'
,
database
=
'ZI_NEW'
,
autocommit
=
True
)
cursor_zi_new
=
conn_zi_new
.
cursor
()
cursor_zi_new
=
conn_zi_new
.
cursor
()
conn_zi_test
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'zgcprice20200628'
,
conn_zi_test
=
pymssql
.
connect
(
host
=
'123.56.115.207'
,
user
=
'zgcprice3311'
,
password
=
'zgcprice20200628'
,
...
@@ -31,13 +31,20 @@ def duplicate_product_update(filepath,sheet_name=0):
...
@@ -31,13 +31,20 @@ def duplicate_product_update(filepath,sheet_name=0):
logname
=
f
"{folderpath}/重复产品更新{timestr}.txt"
logname
=
f
"{folderpath}/重复产品更新{timestr}.txt"
with
open
(
f
"{logname}"
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
f
"{logname}"
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
for
index
,
row
in
df
.
iterrows
():
for
index
,
row
in
df
.
iterrows
():
print
(
f
"index:{index}"
,
file
=
f
)
if
type
(
row
[
'正确产品编码'
])
==
float
:
continue
product_id
=
row
[
'产品编码'
]
product_id
=
row
[
'产品编码'
]
product_id_correct
=
row
[
'正确产品编码'
]
product_id_correct
=
row
[
'正确产品编码'
]
product_name_correct
=
row
[
'正确产品名称'
]
# .split('(')[0].strip()
product_name
=
row
[
'产品名称'
]
product_name_correct
=
row
[
'正确产品名称'
]
if
product_id
==
product_id_correct
and
product_name
==
product_name_correct
:
continue
print
(
f
"index:{index}"
,
file
=
f
)
cursor_zi_new
.
execute
(
f
"update p_sku set state=6, skuname='{product_name_correct}' where sku='{product_id}' "
)
product_name_repeated
=
product_name_correct
+
f
"(sku:{product_id};重复sku:{product_id_correct})"
print
(
f
" if successful: p_sku表,sku编码为'{product_id}'的数据,state被改为6,skuname被改为'{product_name_correct}'"
,
file
=
f
)
cursor_zi_new
.
execute
(
f
"update p_sku set state=6, skuname='{product_name_repeated}' where sku='{product_id}' "
)
print
(
f
" if successful: p_sku表,sku编码为'{product_id}'的数据,state被改为6,skuname被改为'{product_name_repeated}'"
,
file
=
f
)
cursor_zi_new
.
execute
(
f
"update Productcode_Sku set sku='{product_id_correct}' where sku='{product_id}' "
)
cursor_zi_new
.
execute
(
f
"update Productcode_Sku set sku='{product_id_correct}' where sku='{product_id}' "
)
print
(
f
" if successful: Productcode_Sku表,sku编码为'{product_id}'的数据,sku被改为'{product_id_correct}'"
,
file
=
f
)
print
(
f
" if successful: Productcode_Sku表,sku编码为'{product_id}'的数据,sku被改为'{product_id_correct}'"
,
file
=
f
)
cursor_zdindex
.
execute
(
"select top 1 max(periods) from zd_electricity_price"
)
cursor_zdindex
.
execute
(
"select top 1 max(periods) from zd_electricity_price"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment