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
82ca8e14
authored
Jul 30, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
pandas
parent
dec0c886
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletions
waldom_data_process_RMB.py
waldom_data_process_RMB.py
View file @
82ca8e14
import
csv
import
csv
import
json
import
json
import
logging
import
logging
import
pandas
as
pd
logging
.
basicConfig
(
level
=
logging
.
INFO
,
filename
=
'waldom_dollar.log'
,
logging
.
basicConfig
(
level
=
logging
.
INFO
,
filename
=
'waldom_dollar.log'
,
format
=
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s'
)
format
=
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s'
)
logger
=
logging
.
getLogger
(
'waldom_data_process_RMB.py'
)
logger
=
logging
.
getLogger
(
'waldom_data_process_RMB.py'
)
title_map
=
{
title_map
=
{
'Manufacturer Name'
,
'Part Number'
,
'Stock EMEA'
,
'Stock USA'
,
'Stock APAC'
,
'Stock CN'
,
'MOQ'
,
'Price Break Qty 1'
,
'Price Break Qty 2'
,
'Price Break Qty 3'
,
'Price Break Qty 4'
,
'Price Break Qty 5'
,
'Price Break Qty 6'
,
'Price Break Qty 7'
,
'Price Break Qty 8'
,
'Price Break Qty 9'
,
'Date Code'
}
}
class
HandleCSV
:
def
parse
(
self
,
path
):
df
=
pd
.
read_excel
(
path
,
nrows
=
0
)
first_row
=
[]
for
i
in
range
(
len
(
df
.
columns
)):
first_row
.
append
(
df
.
columns
[
i
])
if
not
self
.
validate
(
first_row
):
logger
.
error
(
"文件
%
s 格式错误"
%
path
)
return
[]
print
(
first_row
)
def
validate
(
self
,
arr
:
list
)
->
bool
:
size
=
len
(
title_map
)
count
=
0
for
i
in
range
(
len
(
arr
)):
if
arr
[
i
]
in
title_map
:
count
+=
1
return
count
==
size
if
__name__
==
'__main__'
:
HandleCSV
()
.
parse
(
'Tianyang_Inventory_Feed_RMB.xlsx'
)
...
...
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