当前位置: 首页 > Skill >

CSV

CSV

1.0.0 2026.11.23 浏览:897
获取Skill文件查看使用说明
作者:陈川许可证:
本文目录展开

Quoting Rules

  • Fields containing comma, quote, or newline MUST be wrapped in double quotes
  • Double quotes inside quoted fields escape as "" (two quotes), not backslash
  • Unquoted fields with leading/trailing spaces—some parsers trim, some don't; quote to preserve
  • Empty field ,, vs empty string ,"",—semantically different; be explicit

Delimiters

  • CSV isn't always comma—detect ; (European Excel), t (TSV), | in legacy systems
  • Excel exports use system locale delimiter; semicolon common in non-US regions
  • Sniff delimiter from first line but verify—header might not contain special chars

Encoding

  • UTF-8 BOM (0xEF 0xBB 0xBF) breaks naive parsers but Excel needs it for UTF-8 detection
  • When generating for Excel on Windows: add BOM; for programmatic use: omit BOM
  • Latin-1 vs UTF-8 ambiguity—explicitly declare or detect encoding before parsing

Common Parsing Failures

  • Newlines inside quoted fields are valid—don't split on n before parsing
  • Unescaped quote in middle of field corrupts rest of file—validate early
  • Trailing newline at EOF—some parsers create empty last row; strip or handle
  • Inconsistent column count per row—validate all rows match header count

Numbers & Dates

  • 1,234.56 vs 1.234,56—locale-dependent; standardize or document format
  • Dates: ISO 8601 (2024-01-15) only unambiguous format; 01/02/24 is chaos
  • Leading zeros in numeric fields (007)—quote to preserve or document as string

Excel Quirks

  • Formula injection: fields starting with =, +, -, @ execute as formulas—prefix with ' or tab
  • Long numbers (>15 digits) lose precision—quote and format as text
  • Scientific notation triggered by E in numbers—quote if literal text needed

相关文章

更多
PHP导出CSV文件内容为空或只有表头的原因排查

排查 PHP 导出 CSV 文件为空或只有表头,核心是检查输出缓冲( Output Buffering )是否被意外清空、字符编码( BOM )是否干扰了内容显示,以及是否存在未捕获的致命错误导致脚本提前终止。直接关闭所有缓冲并强制刷新缓冲区通常能解决大部分问题。

2025.10.14 824
修复PHP导出CSV后Excel提示文件格式错误或内容截断

在 PHP 中导出 CSV 时,若 Excel 提示格式错误或内容截断,核心原因是未正确输出 BOM 头导致中文乱码,以及未处理数据中的特殊字符。解决方法是:使用 fputcsv 生成数据,并在文件头部添加 UTF -8 BOM ( \xEF\xBB\xBF ),同时确保所有字符串字段已正确转义。

2026.04.19 667
解决PHP导出CSV文件在Excel中中文显示乱码的问题

在 PHP 中导出 CSV 文件时,若 Excel 打开中文显示为乱码,核心原因是 Excel 默认使用 GBK / GB2312 编码解析本地 CSV ,而现代 PHP 脚本通常输出 UTF -8。解决方法是在输出 CSV 内容前,强制写入 UTF -8 BOM (字节顺序标记) \xEF\xBB\xBF ,并确保

2025.03.12 485
PHP直接将MySQL查询结果导出为CSV文件的低内存写法

使用 SELECT ... INTO OUTFILE 语句由 MySQL 服务端直接生成 CSV , PHP 仅负责执行 SQL 并处理文件路径与权限,避免在 PHP 内存中构建大数组。

2025.09.04 483
PHP怎么将数组导出为CSV并触发浏览器下载

使用 fputcsv 将数组写入 php://output ,配合 header 设置响应头即可触发浏览器下载。

2025.07.22 396
PHP使用fputcsv导出数组为CSV文件的完整代码示例

使用 fputcsv 函数逐行写入数据即可高效导出数组为 CSV ,无需一次性加载大文件到内存。

2026.10.08 332
Skill 文件

相关 Skill

更多
CSV解析与生成 CSV解析与生成 解析与生成RFC 4180合规的CSV,处理引号、分隔符、编码、数字日期与Excel特性,跨工具兼容。
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...