
成果範例
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.
客戶與所有細節皆為虛構。
關於此服務
供應商價目表、銀行或電商平台報表和庫存清單常常只有 PDF 版本,把表格複製到 Excel 時欄位又會亂掉。這個 Python 腳本會讀取 PDF 中的表格,並把它們寫入 Excel 或 CSV,欄位各就各位:它會把跨越多頁的表格接起來,去掉重複的標題列和頁尾;標準版起,還會把 1 234,50 或 (120.00) 轉成真正的數字,日期也轉成日期格式。腳本是針對您檔案的版面調整的,所以請提供一兩個典型的 PDF,或版面相同但數字虛構的檔案。PDF 必須含有真實文字,大多數從程式另存的檔案都是如此;掃描檔和紙本照片需要文字辨識,這不在服務範圍內。腳本由您自己執行,並請核對總計。
包含內容
- 您會得到一個 ZIP 壓縮檔,內含 Python 腳本、附逐步說明的 README,標準版起另附記錄欄位名稱和頁面的設定檔;訂單頁面上也會顯示程式碼。
- 針對您的版面調整依您提供的範例檔案製作並測試
- 欄位各就各位PDF 中的一列就是 Excel 中的一列
- 多頁接續長表格變成一個工作表,沒有重複的標題列
- 真正的數字標準版起,金額和日期都能加總和排序
- 易讀的程式碼附有註解,版面變動時很容易調整
服務流程
- 1範例您提供一兩個典型 PDF,並指出您需要的表格
- 2程式碼我們針對該版面撰寫腳本和執行說明
- 3試跑您用自己的檔案執行,並與 PDF 核對總計
- 4修改您在方案範圍內提出修改,並附上任何錯誤訊息
需要您提供的資料
一兩個您會收到的典型 PDF(或版面相同但名稱和數字虛構的檔案)、您需要哪幾頁的哪個表格,以及您在 Excel 中想要的欄位。其中的數字怎麼寫(逗號、空格、負號或括號)以及日期格式。您所有的檔案是同一種版面還是有好幾種、大約要處理多少個檔案,以及您的系統:Windows、macOS 或 Linux。
我們會詢問您:
- 是哪些 PDF?
- 您在 Excel 中需要哪些欄位?
- 您的檔案都長得一樣嗎?
- 要在哪裡執行?
比較方案
付款保障
下單時付款,但只有在驗收成果後,款項才會撥付。
- 固定價格付款後,方案價格不會變動。
- 款項先行保留付款時,金額只會先保留,在您驗收後才會撥付給服務。
- 交付前檢查每份成果在交到您手上之前都會經過品質檢查,您也可以在驗收前於訂單頁面查看成果。
- 免費修改在需求說明範圍內,可依方案允許的次數提出修改。
- 3 天後自動驗收若您在交付後 3 天內未驗收也未提出修改,成果將自動驗收。若您在交付後於訂單聊天室留言,訂單會暫停自動驗收;我們回覆後,可能會重新起算 3 天,並會在聊天室中告知。
- 重新製作或全額退款若成果不符合您的需求說明且修改後仍未改善,或製作時間超過交付期限的兩倍,請在訂單聊天室留言:我們將重新製作,或全額退還款項。
常見問題
任何 PDF 都適用嗎?
它是針對您範例檔案的版面製作的。如果供應商更改了版面,腳本可能需要調整。不含真實文字的 PDF(例如掃描檔)不在範圍內。
我要怎麼知道 PDF 有沒有真實文字?
打開檔案,試著用滑鼠選取一個字。如果可以選取和複製,就是真實文字。如果整頁被選成一張圖片,那就是掃描檔。
會出錯嗎?
會,PDF 中的表格並不是以表格形式儲存的,所以一條奇怪的線就可能讓某一列跑掉。因此腳本會記錄它沒把握的頁面,在使用結果之前,請先與 PDF 核對總計。
我一定要提供真實的報表嗎?
不用。版面相同、數字虛構的檔案效果一樣好,之後腳本會在您的電腦上處理您的真實檔案。
沒有找到您要的答案?