Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
my-awesome-project
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6e7e8746
authored
Jul 30, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add new line
parent
c746c4ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
6 deletions
waldom_data_process_RMB.py
waldom_data_process_RMB.py
View file @
6e7e8746
import
csv
import
json
import
logging
import
time
import
openpyxl
import
pandas
as
pd
...
...
@@ -46,8 +46,15 @@ class HandleCSV:
logger
.
error
(
"文件
%
s 格式错误"
%
path
)
return
[]
for
i
in
range
(
len
(
df
.
index
.
values
)):
if
i
>
100
:
break
# print(df.loc[i, title_arr[0]])
table
=
dict
()
table
[
'price_is_us'
]
=
False
table
[
'ladder_price'
]
=
[]
table
[
'supplier_name'
]
=
'Waldom人民币'
table
[
'goods_sn'
]
=
''
batch_sn_map
=
dict
()
for
j
in
range
(
len
(
title_arr
)):
ladder_item_map
=
dict
()
data
=
df
.
loc
[
i
,
title_arr
[
j
]]
...
...
@@ -67,11 +74,29 @@ class HandleCSV:
elif
title_arr
[
j
]
==
'MOQ'
:
table
[
'moq'
]
=
data
elif
title_arr
[
j
]
in
ladder_map
:
ladder_item_map
[
'purchases'
]
=
int
(
data
)
ladder_item_map
[
'price_us'
]
=
float
(
0
)
ladder_item_map
[
'price_cn'
]
=
float
(
df
.
loc
[
i
,
ladder_map
[
title_arr
[
j
]]])
if
len
(
str
(
data
)
.
strip
())
!=
0
and
str
(
data
)
.
strip
()
.
isdigit
():
ladder_item_map
[
'purchases'
]
=
int
(
data
)
ladder_item_map
[
'price_us'
]
=
float
(
0
)
ladder_item_map
[
'price_cn'
]
=
float
(
df
.
loc
[
i
,
ladder_map
[
title_arr
[
j
]]])
table
[
'ladder_price'
]
.
append
(
ladder_item_map
)
elif
title_arr
[
j
]
==
'Date Code'
:
pass
item_arr
=
str
(
data
)
.
split
(
sep
=
";"
)
for
k
in
range
(
len
(
item_arr
)):
item
=
item_arr
[
k
]
split_item_arr
=
item
.
split
(
sep
=
"|"
)
if
len
(
split_item_arr
)
==
3
:
number
=
split_item_arr
[
0
]
.
strip
()
year
=
split_item_arr
[
1
]
.
strip
()
if
len
(
number
)
>
0
and
len
(
year
)
>=
4
and
number
.
isdigit
()
and
str
(
year
[
len
(
year
)
-
4
:])
.
isdigit
():
key
=
str
(
year
[
len
(
year
)
-
2
:])
+
"+"
value
=
number
if
key
in
batch_sn_map
:
batch_sn_map
[
key
]
+=
int
(
value
)
else
:
batch_sn_map
[
key
]
=
int
(
value
)
table
[
'batch_sn'
]
=
batch_sn_map
json_str
=
json
.
dumps
(
table
,
ensure_ascii
=
False
)
print
(
json_str
)
...
...
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