
成果範例
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.
客戶與所有細節皆為虛構。
關於此服務
您商店平台的訂單、專案管理服務的任務、預約系統的紀錄:只要該服務有公開 API,資料就能直接進入您的 Google 試算表,不必手動匯出檔案。這個 Google Apps Script 會用您自己的金鑰向 API 發出請求,取出您需要的欄位,一頁一頁寫成資料列。標準版起,金鑰放在由您填寫的指令碼屬性中,而不是程式碼裡,錯誤則會寫到記錄分頁;進階版只新增新的或有變更的列,並附上用觸發條件每小時或每天執行的說明。請提供 API 文件的連結和您需要的欄位。單次執行時間上限約六分鐘,所以非常大量的匯入會分批進行。
包含內容
- 您會得到一個 ZIP 壓縮檔,內含 Apps Script 程式碼和 README,說明如何加到您的試算表、填入金鑰並執行;訂單頁面上也會顯示程式碼。
- 依照技術文件依 API 本身的文件撰寫
- 欄位由您選擇只放您需要的欄位,依您的順序
- 讀取所有頁面分頁回傳的結果會一直讀到最後
- 金鑰不寫進程式碼由您自己填入指令碼屬性
- 易讀的程式碼附有註解,日後很容易新增欄位
服務流程
- 1任務您提供 API 文件和需要的欄位
- 2程式碼我們依文件撰寫腳本和安裝說明
- 3試跑您在試算表的副本中填入金鑰並執行
- 4修改您在方案範圍內提出修改,並附上任何錯誤訊息
需要您提供的資料
服務名稱和其 API 文件的連結、您需要的請求(例如過去 30 天的訂單),以及要變成欄位的資料項目。提供一份 API 回應範例會很有幫助:從文件中複製,或從測試呼叫中複製並移除私人資料。資料要多久更新一次,以及是新增資料列還是覆寫整張試算表。請絕對不要提供您真實的 API 金鑰:README 會說明要放在哪裡。
我們會詢問您:
- 哪個服務?它的 API 文件在哪裡?
- 您需要哪些資料?
- 多久要更新一次?
比較方案
付款保障
下單時付款,但只有在驗收成果後,款項才會撥付。
- 固定價格付款後,方案價格不會變動。
- 款項先行保留付款時,金額只會先保留,在您驗收後才會撥付給服務。
- 交付前檢查每份成果在交到您手上之前都會經過品質檢查,您也可以在驗收前於訂單頁面查看成果。
- 免費修改在需求說明範圍內,可依方案允許的次數提出修改。
- 3 天後自動驗收若您在交付後 3 天內未驗收也未提出修改,成果將自動驗收。若您在交付後於訂單聊天室留言,訂單會暫停自動驗收;我們回覆後,可能會重新起算 3 天,並會在聊天室中告知。
- 重新製作或全額退款若成果不符合您的需求說明且修改後仍未改善,或製作時間超過交付期限的兩倍,請在訂單聊天室留言:我們將重新製作,或全額退還款項。
常見問題
任何服務都適用嗎?
適用於有公開 API、並讓您取得自己金鑰或 token 的服務。沒有 API 的服務,或每次都要透過瀏覽器頁面登入的服務,不在範圍內。
多久可以更新一次?
使用時間觸發條件,最快可以每幾分鐘一次,不過大多數資料每小時或每天執行就夠了。該服務本身的請求限制,以及 Google 對指令碼的限制都適用。
可以把資料傳回該服務嗎?
這項服務負責把資料讀進試算表。如果 API 允許,也可以寫回;請在需求說明中描述,我們會說明是否在您的方案範圍內。
你們會幫我申請金鑰嗎?
不會。金鑰由您在自己的服務帳戶中建立,並由您自己填入指令碼屬性。我們絕不登入您的帳戶。
沒有找到您要的答案?