Commit 82ca8e14 by larosa

pandas

parent dec0c886
Showing with 31 additions and 1 deletions
import csv
import json
import logging
import pandas as pd
logging.basicConfig(level=logging.INFO, filename='waldom_dollar.log',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger('waldom_data_process_RMB.py')
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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment