资源
- Overview
- 快速入门
- Claude 3 模型卡
- Claude 3.7 系统卡
- 系统状态
- Anthropic 课程
- 提示词库
- 提示词库
- 宇宙键盘
- 企业预见者
- 网站向导
- Excel公式专家
- Google Apps 脚本编写者
- Python 错误修复器
- 时间旅行顾问
- 讲故事助手
- 引用你的来源
- SQL 魔法师
- 解梦师
- 双关语大师
- 烹饪创作者
- 混合词诗人
- 幽默助手哈尔
- LaTeX 指南
- 情绪色彩转换器
- Git 精通
- 比喻大师
- 伦理困境导航器
- 会议记录员
- 成语解析器
- 代码顾问
- 函数制造者
- 新词创造者
- CSV 转换器
- 表情符号编码器
- 文章润色师
- 观点权衡者
- 琐事生成器
- 正念导师
- 二年级简化器
- VR健身创新者
- PII 净化器
- 备忘录大师
- 职业教练
- 评分大师
- 绕口令
- 面试问题设计师
- 语法精灵
- 猜谜语
- 代码解释器
- 外星人类学家
- 数据整理器
- 品牌构建者
- 效率估算器
- 评论分类器
- 方向解码器
- 激励缪斯
- 电子邮件提取器
- 专业审核员
- 课程计划制定者
- 苏格拉底式智者
- 头韵炼金术师
- 未来主义时尚顾问
- 多语言超能力
- 产品命名专家
- 哲学沉思
- 电子表格魔术师
- 科幻场景模拟器
- 自适应编辑器
- 巴别塔的广播
- 推文语调检测器
- 机场代码分析器
提示词库
CSV 转换器
将数据从各种格式(JSON、XML 等)转换为格式正确的 CSV 文件。
将此提示复制到我们的开发者控制台中,亲自尝试!
内容 | |
---|---|
System | 作为数据转换专家,您的任务是将不同格式(JSON、XML 等)的数据转换为格式正确的 CSV 文件。用户将提供原始格式的输入数据,以及 CSV 输出的任何特定要求或偏好(例如,列顺序、分隔符、编码)。确保您清楚地理解数据结构和所需的 CSV 格式,必要时提出澄清问题。一旦您获得了必要的信息,请通过遵循适当的格式规则生成 CSV 输出,例如使用逗号作为分隔符,必要时将值括在引号中,并正确处理特殊字符或换行符。最后,提供有关保存或使用 CSV 文件的任何其他说明或提示。 |
User | 请将以下 JSON 数据转换为 CSV 文件: [ { “name”: “John Doe”, “age”: 30, “city”: “New York”, “email”: “john.doe@example.com” }, { “name”: “Jane Smith”, “age”: 25, “city”: “London”, “email”: “jane.smith@example.com” }, { “name”: “Bob Johnson”, “age”: 35, “city”: “Paris”, “email”: “bob.johnson@example.com” } ] 要求: - CSV 中的列应按以下顺序排列:name, age, city, email - 使用分号(;)作为分隔符 - 将所有值括在双引号(“)中 |
示例输出
根据提供的 JSON 数据和要求,以下是转换后的 CSV 文件:
csv
"name";"age";"city";"email"
"John Doe";"30";"New York";"john.doe@example.com"
"Jane Smith";"25";"London";"jane.smith@example.com"
"Bob Johnson";"35";"Paris";"bob.johnson@example.com"
解释:
- CSV 文件的第一行包含列标题:“name”、“age”、“city”和”email”,用分号(;)分隔并用双引号(“)括起来。
- 每个后续行代表一行数据,值用分号(;)分隔并用双引号(“)括起来。
- 每行中值的顺序对应指定的列顺序:name、age、city 和 email。
- 值中存在的特殊字符(如果有)在双引号内保留。
保存 CSV 文件的方法:
- 复制上面提供的 CSV 数据。
- 打开文本编辑器(例如记事本、TextEdit 或任何其他纯文本编辑器)。
- 将 CSV 数据粘贴到文本编辑器中。
- 使用 .csv 扩展名保存文件(例如 data.csv)。
注意:在电子表格应用程序(例如 Microsoft Excel、Google Sheets)中打开 CSV 文件时,确保指定正确的分隔符(分号)和值周围的双引号,以确保正确格式化。
API 请求
import anthropic
client = anthropic.Anthropic( # 默认为 os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": 'Please convert the following JSON data into a CSV file: \n \n[ \n { \n "name": "John Doe", \n "age": 30, \n "city": "New York", \n "email": "[email protected]" \n }, \n { \n "name": "Jane Smith", \n "age": 25, \n "city": "London", \n "email": "[email protected]" \n }, \n { \n "name": "Bob Johnson", \n "age": 35, \n "city": "Paris", \n "email": "[email protected]" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (")',
}
],
}
],
)
print(message.content)
import anthropic
client = anthropic.Anthropic( # 默认为 os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": 'Please convert the following JSON data into a CSV file: \n \n[ \n { \n "name": "John Doe", \n "age": 30, \n "city": "New York", \n "email": "[email protected]" \n }, \n { \n "name": "Jane Smith", \n "age": 25, \n "city": "London", \n "email": "[email protected]" \n }, \n { \n "name": "Bob Johnson", \n "age": 35, \n "city": "Paris", \n "email": "[email protected]" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (")',
}
],
}
],
)
print(message.content)
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: "my_api_key", // 默认为 process.env["ANTHROPIC_API_KEY"]
});
const msg = await anthropic.messages.create({
model: "claude-opus-4-20250514",
max_tokens: 1000,
temperature: 0,
system: "As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please convert the following JSON data into a CSV file: \n \n[ \n { \n \"name\": \"John Doe\", \n \"age\": 30, \n \"city\": \"New York\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Jane Smith\", \n \"age\": 25, \n \"city\": \"London\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Bob Johnson\", \n \"age\": 35, \n \"city\": \"Paris\", \n \"email\": \"[email protected]\" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (\")"
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicBedrock
# 参见 https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
# 了解认证选项
client = AnthropicBedrock()
message = client.messages.create(
model="anthropic.claude-opus-4-20250514-v1:0",
max_tokens=1000,
temperature=0,
system="As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please convert the following JSON data into a CSV file: \n \n[ \n { \n \"name\": \"John Doe\", \n \"age\": 30, \n \"city\": \"New York\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Jane Smith\", \n \"age\": 25, \n \"city\": \"London\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Bob Johnson\", \n \"age\": 35, \n \"city\": \"Paris\", \n \"email\": \"[email protected]\" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (\")"
}
]
}
]
)
print(message.content)
import AnthropicBedrock from "@anthropic-ai/bedrock-sdk";
// 参见 https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
// 了解认证选项
const client = new AnthropicBedrock();
const msg = await client.messages.create({
model: "anthropic.claude-opus-4-20250514-v1:0",
max_tokens: 1000,
temperature: 0,
system: "As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please convert the following JSON data into a CSV file: \n \n[ \n { \n \"name\": \"John Doe\", \n \"age\": 30, \n \"city\": \"New York\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Jane Smith\", \n \"age\": 25, \n \"city\": \"London\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Bob Johnson\", \n \"age\": 35, \n \"city\": \"Paris\", \n \"email\": \"[email protected]\" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (\")"
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicVertex
client = AnthropicVertex()
message = client.messages.create(
model="claude-3-sonnet@20240229",
max_tokens=1000,
temperature=0,
system="As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please convert the following JSON data into a CSV file: \n \n[ \n { \n \"name\": \"John Doe\", \n \"age\": 30, \n \"city\": \"New York\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Jane Smith\", \n \"age\": 25, \n \"city\": \"London\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Bob Johnson\", \n \"age\": 35, \n \"city\": \"Paris\", \n \"email\": \"[email protected]\" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (\")"
}
]
}
]
)
print(message.content)
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
// 从 `CLOUD_ML_REGION` 和 `ANTHROPIC_VERTEX_PROJECT_ID` 环境变量读取。
// 此外,还通过标准 `google-auth-library` 流程进行。
const client = new AnthropicVertex();
const msg = await client.messages.create({
model: "claude-3-sonnet@20240229",
max_tokens: 1000,
temperature: 0,
system: "As a data conversion expert, your task is to convert data from different formats (JSON, XML, etc.) into properly formatted CSV files. The user will provide the input data in the original format, along with any specific requirements or preferences for the CSV output (e.g., column order, delimiter, encoding). Ensure that you have a clear understanding of the data structure and the desired CSV format, asking any clarifying questions as needed. Once you have the necessary information, generate the CSV output by following the appropriate formatting rules, such as using commas as delimiters, enclosing values in quotes if necessary, and handling special characters or line breaks correctly. Finally, provide any additional instructions or tips for saving or using the CSV file.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please convert the following JSON data into a CSV file: \n \n[ \n { \n \"name\": \"John Doe\", \n \"age\": 30, \n \"city\": \"New York\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Jane Smith\", \n \"age\": 25, \n \"city\": \"London\", \n \"email\": \"[email protected]\" \n }, \n { \n \"name\": \"Bob Johnson\", \n \"age\": 35, \n \"city\": \"Paris\", \n \"email\": \"[email protected]\" \n } \n] \n \nRequirements: \n- Columns in the CSV should be in the order: name, age, city, email \n- Use semicolons (;) as delimiters \n- Enclose all values in double quotes (\")"
}
]
}
]
});
console.log(msg);