Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
europa-erp-python
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
2ed57ce0
authored
Sep 18, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add hk_cn
parent
52554d47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
13 deletions
rs_data.py
template/sku_data.json
rs_data.py
View file @
2ed57ce0
...
...
@@ -35,12 +35,13 @@ conf = config.load_config_map()
def
handle_
standard
_csv
(
file_name
):
def
handle_
hk
_csv
(
file_name
):
"""handle the csv file witch separator is ',' """
with
open
(
file_name
,
errors
=
'ignore'
)
as
f
:
reader
=
csv
.
reader
(
f
)
title
=
[]
for
index
,
row
in
enumerate
(
reader
):
# TODO remember to delete.
if
index
>
10
:
break
if
index
==
0
:
...
...
@@ -48,32 +49,50 @@ def handle_standard_csv(file_name):
continue
message_map
=
dict
()
ladder_number
=
[]
ladder_price_item
=
dict
()
ladder_price
=
[]
prices
=
[]
for
i
in
range
(
len
(
row
)):
message_map
[
'batch_sn'
]
=
{}
message_map
[
'eccn'
]
=
''
message_map
[
'goods_details'
]
=
''
if
title
[
i
]
==
'DistributorPartNumber'
:
message_map
[
"goods_sn"
]
=
row
[
i
]
# TODO origin goods_sn + supplier_id
message_map
[
"goods_sn"
]
=
str
(
row
[
i
])
+
"_"
if
title
[
i
]
==
'ManufacturerPartNumber'
:
message_map
[
'goods_name'
]
=
row
[
i
]
message_map
[
'goods_name'
]
=
str
(
row
[
i
])
if
title
[
i
]
==
'Manufacturer'
:
message_map
[
'brand_name'
]
=
row
[
i
]
message_map
[
'brand_name'
]
=
str
(
row
[
i
])
if
title
[
i
]
==
'QuantityAvailable'
:
message_map
[
'stock'
]
=
row
[
i
]
message_map
[
'stock'
]
=
str
(
row
[
i
])
if
title
[
i
]
==
'PriceQuantity'
:
ladder_number
=
row
[
i
]
.
split
(
sep
=
"|"
)
# TODO not sure about the price.
message_map
[
'moq'
]
=
ladder_number
[
0
]
message_map
[
'moq'
]
=
str
(
ladder_number
[
0
])
if
title
[
i
]
==
'PACK_SIZE'
:
message_map
[
'multiple'
]
=
row
[
i
]
message_map
[
'mpq'
]
=
row
[
i
]
message_map
[
'multiple'
]
=
str
(
row
[
i
])
message_map
[
'mpq'
]
=
str
(
row
[
i
])
if
title
[
i
]
==
'IMAGE_URL'
:
message_map
[
'goods_images'
]
=
row
[
i
]
message_map
[
'goods_images'
]
=
str
(
row
[
i
])
# the price is hkd, but store in 'usd' column.
if
title
[
i
]
==
'HKD_1_Price'
or
title
[
i
]
==
'HKD_2_Price'
\
or
title
[
i
]
==
'HKD_3_Price'
or
title
[
i
]
==
'HKD_4_Price'
\
or
title
[
i
]
==
'HKD_5_Price'
:
if
row
[
i
]
==
''
or
len
(
row
[
i
])
==
0
:
continue
prices
.
append
(
row
[
i
])
for
i
in
range
(
min
(
len
(
ladder_number
),
len
(
prices
))):
item_map
=
dict
()
item_map
[
"purchases"
]
=
int
(
ladder_number
[
i
])
item_map
[
"price_us"
]
=
float
(
prices
[
i
])
item_map
[
"price_cn"
]
=
float
(
0
)
ladder_price
.
append
(
item_map
)
message_map
[
"ladder_price"
]
=
ladder_price
json_str
=
json
.
dumps
(
message_map
)
print
(
json_str
)
def
handle_cn_csv
():
pass
...
...
@@ -109,7 +128,7 @@ if __name__ == '__main__':
# file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_3, extract_dir)
"""handle the file and then post to rabbitmq"""
handle_
standard
_csv
(
extract_dir
+
handle_file_name_1
)
handle_
hk
_csv
(
extract_dir
+
handle_file_name_1
)
# handle_standard_csv(extract_dir + handle_file_name_2)
# handle_standard_csv(extract_dir + handle_file_name_3)
...
...
template/sku_data.json
View file @
2ed57ce0
{
"goods_sn"
:
"1 col"
,
"goods_sn"
:
"1 col
"
,
"goods_name"
:
" 2 col"
,
"brand_name"
:
"3 col"
,
"stock"
:
"quanti availble"
,
...
...
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