DeepSeek+Google Sheet批量处理数据
我的需求
我有一堆格式各不相同的服装尺码表,需要处理成统一的格式,以便在我的网站显示。例如,将以下
US Size UK Size EU Size Blazer Length Bust Shoulder Sleeve Pants Length Waist Hips
S 4 8 - 10 36 - 38 77 104 35 63.5 114 64 98
M 6 12 - 14 40 - 42 78 108 36 64 115 68 102
L 8/10 16 - 18 44 - 46 79 112 37 64.5 116 72 106
处理为
Size,Us Size,Uk Size,Eu Size,Bust,Waist,Hips,Length,Sleeve|S,4,8 - 10,36 - 38,29.1/74,24/61,31.5/80,51.2/130,26/66|M,6,12 - 14,40 - 42,30.7/78,25.6/65,33.1/84,52/132,26.5/67.2|L,8/10,16 - 18,44 - 46,33.1/84,28/71,35.4/90,52.8/134,26.9/68.4|XL,12,20 - 22,48 - 50,35.4/90,30.3/77,37.8/96,53.5/136,27.4/69.6
步骤
- 创建Google Sheet
导出产品,创建原始数据列和处理后数据列
- 点击Apps Script
- 粘贴以下代码
提示:有很多低价API中转,可以自行搜索
填好API_KEY、API_URL,在content中写好你的数据处理需求
const API_KEY = "你的API密钥";
const API_URL = "https://api.deepseek.com/v1/chat/completions"; // 替换为实际API端点
function DS_PROCESS(input) {
if (!input) return "";
const payload = {
model: "deepseek-v3", // 根据实际模型修改
messages: [{
role: "user",
content: "这里写你的数据处理需求" + input + "。重要:仅输出数据不要输出其他内容"
}],
temperature: 0.7
};
const options = {
method: "post",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
try {
const response = UrlFetchApp.fetch(API_URL, options);
const json = JSON.parse(response.getContentText());
return json.choices[0].message.content;
} catch (e) {
return "错误:" + e.toString();
}
}
- 点击右上角的部署,类型选择Web App
- 在表格中使用
- 假设要处理C列数据
- 在D2单元格输入公式:
=DS_PROCESS(C2)
- 向下拖动表格,即可批量处理数据,如图
预告
下期出一个尺码表教学,针对的需求是每一个商品尺码表都不同
无需插件,完全免费!而且实现只需简单3步!效果参照下面
福利
Shopify3个月1刀试用、WordPress主机8折(一年只要100多R)