
成果範例
Merging the monthly sales files of 9 shops into one Excel report
How it is run
python merge_sales.py --month 2026-10
2026-11-02 09:14:03 INFO Folder: sales/2026-10, 9 files found
2026-11-02 09:14:03 INFO shop-01.csv: 1,284 rows
2026-11-02 09:14:04 INFO shop-02.xlsx: 967 rows
2026-11-02 09:14:04 WARN shop-07.csv: 3 rows without a price skipped (lines 88, 412, 913)
2026-11-02 09:14:05 INFO Done: 10,412 rows -> report-2026-10.xlsx (sheets "Sales" and "Totals")
Settings, not code
The column names of each shop live in settings.ini, so a new shop or a renamed column is a line there:
[columns]
date = Date, Sale date, Day
product = Product, Item, Name
quantity = Qty, Quantity, Pcs
price = Price, Unit price
A part of the code
def read_shop_file(path: Path, columns: dict[str, list[str]]) -> pd.DataFrame:
"""Reads one shop's file and gives it the report's column names."""
table = pd.read_excel(path) if path.suffix == ".xlsx" else pd.read_csv(path, encoding="utf-8-sig")
renamed = {}
for name, variants in columns.items():
found = next((c for c in table.columns if c.strip() in variants), None)
if found is None:
raise ReportError(f"{path.name}: no column for '{name}' (looked for {', '.join(variants)})")
renamed[found] = name
table = table.rename(columns=renamed)[list(columns)]
table["shop"] = path.stem
return table
Files: a ZIP archive with merge_sales.py (310 lines), settings.ini, requirements.txt and a README with installing Python, running the script and what each message in the log means. The client runs it on their own computer.
Client: a small chain of 9 stationery shops; each shop sends its sales for the month as a CSV or Excel file, with slightly different column names. Task: one script that reads every file in a folder, brings the columns to one shape, and writes a single Excel report with all sales and a sheet of totals by shop.
客戶與所有細節皆為虛構。
關於此服務
WooCommerce 有自己的商品匯入工具,但它要求特定欄位:Type、SKU、Name、Regular price、以 > 分隔層級的 Categories、以連結提供的圖片;服裝或其他有選項的商品,則需要一個父商品,加上以 Parent 連結的每個變化款式各一列。這個 Python 腳本會把您的供應商價目表、其他商店的匯出檔或您自己的表格轉成這種檔案。它會對應您的欄位、建立分類;標準版起,還會建立帶有尺寸、顏色等屬性的可變商品,並列出缺少價格、SKU 或圖片的資料列。圖片必須放在您網站能下載的連結上。匯入工具由您自己在 WordPress 後台執行;我們絕不登入您的網站。請先用幾項商品試試看,並保留商店的備份。
包含內容
- 您會得到一個 ZIP 壓縮檔,內含 Python 腳本、附逐步說明的 README,標準版起另附記錄欄位對應的設定檔;訂單頁面上也會顯示程式碼。
- WooCommerce 的欄位符合其內建商品匯入工具的要求
- 變化款式相互連結標準版起,父商品附尺寸和顏色
- 多層分類Clothes > Women > Dresses,與 WooCommerce 的讀取方式一致
- 列出問題回報缺少價格、SKU 或圖片的資料列
- 易讀的程式碼附有註解,日後很容易新增欄位
服務流程
- 1檔案您提供商品檔案的範例,並說明什麼對應到哪裡
- 2程式碼我們撰寫腳本和執行說明
- 3試跑您在商店副本或測試網站上匯入幾項商品
- 4修改您在方案範圍內提出修改,並附上任何錯誤訊息
需要您提供的資料
您商品檔的 20–30 列、其中選項的寫法(每個尺寸一列,或所有尺寸寫在同一格)、您的分類架構、圖片在哪裡(連結,或已在 WordPress 媒體庫中的檔案),以及價格如何設定。提供從您 WooCommerce 商店匯出的幾項商品,有助於讓欄位完全一致。您的系統:Windows、macOS 或 Linux。
我們會詢問您:
- 您現在有什麼檔案?
- 您的商品有選項嗎?
- 您的分類架構是什麼?
- 圖片在哪裡?
比較方案
付款保障
下單時付款,但只有在驗收成果後,款項才會撥付。
- 固定價格付款後,方案價格不會變動。
- 款項先行保留付款時,金額只會先保留,在您驗收後才會撥付給服務。
- 交付前檢查每份成果在交到您手上之前都會經過品質檢查,您也可以在驗收前於訂單頁面查看成果。
- 免費修改在需求說明範圍內,可依方案允許的次數提出修改。
- 3 天後自動驗收若您在交付後 3 天內未驗收也未提出修改,成果將自動驗收。若您在交付後於訂單聊天室留言,訂單會暫停自動驗收;我們回覆後,可能會重新起算 3 天,並會在聊天室中告知。
- 重新製作或全額退款若成果不符合您的需求說明且修改後仍未改善,或製作時間超過交付期限的兩倍,請在訂單聊天室留言:我們將重新製作,或全額退還款項。
常見問題
我需要付費的匯入外掛嗎?
不需要。檔案是為 WooCommerce 內建的商品匯入工具(「商品」>「匯入」)製作的。其他匯入外掛使用不同的格式;如果您有在用,請告訴我們。
可以更新現有商品嗎?
可以:匯入時勾選更新選項,WooCommerce 就能更新 SKU 或 ID 相符的商品。進階版會依供應商的新價目表,按 SKU 準備更新用檔案。
如果匯入出錯怎麼辦?
所以才要先用幾項商品試試看,最好是在商店的副本上,並保留備份。匯入工具本身無法復原已完成的匯入。
你們會幫我匯入商品嗎?
不會。我們絕不登入您的網站。匯入工具由您自己執行,README 會說明每個步驟。
沒有找到您要的答案?