Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
saturn
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
alpha
saturn
Commits
4205fb3e
Commit
4205fb3e
authored
Jan 02, 2019
by
王浩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add reptile nice tag script
parent
9ea773c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
read_excel.py
api/utils/read_excel.py
+57
-0
No files found.
api/utils/read_excel.py
0 → 100644
View file @
4205fb3e
from
xlrd
import
open_workbook
from
urllib.request
import
urlopen
,
Request
from
urllib
import
parse
import
json
import
math
import
requests
PAGE_SIZE
=
100
def
read_excel
():
wb
=
open_workbook
(
filename
=
'/Users/apple/Desktop/nice_tag20181225.xlsx'
)
sheet1
=
wb
.
sheet_by_index
(
0
)
tags
=
[]
for
i
in
range
(
1
,
sheet1
.
nrows
):
item
=
sheet1
.
row_values
(
i
)
if
item
:
if
item
[
1
]:
tags
.
append
({
'name'
:
item
[
1
],
'img'
:
item
[
-
1
]})
print
(
len
(
tags
))
return
tags
def
create_tags
(
tags
):
url
=
'http://127.0.0.1:8090/api/v1/create_tag_for_batch'
post_data
=
json
.
dumps
(
tags
)
textmod
=
{
"tags"
:
post_data
}
print
(
textmod
)
req
=
requests
.
post
(
url
=
url
,
data
=
textmod
)
print
(
req
.
text
)
def
process
():
tags
=
read_excel
()
# create_tags([{"name": "aaa", "img": "http://www.baidu.com"}, {"name": "bbb", "img": "http://www.baidu.com"}])
count
=
math
.
ceil
(
len
(
tags
)
/
PAGE_SIZE
)
print
(
count
)
for
i
in
range
(
0
,
count
):
if
i
==
5
:
break
if
i
<
4
:
continue
print
(
i
)
item
=
tags
[
PAGE_SIZE
*
i
:
PAGE_SIZE
*
i
+
PAGE_SIZE
]
# print(item, len(item))
create_tags
(
item
)
if
__name__
==
"__main__"
:
process
()
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