惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
大猫的无限游戏
大猫的无限游戏
NISL@THU
NISL@THU
Scott Helme
Scott Helme
G
Google Developers Blog
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Cloudflare Blog
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cisco Blogs
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Forbes - Security
Forbes - Security
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
S
Security Affairs
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy & Cybersecurity Law Blog
Martin Fowler
Martin Fowler
Know Your Adversary
Know Your Adversary
F
Full Disclosure
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
博客园 - Franky
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
T
Tenable Blog
V
V2EX
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

博客园 - Jiger

TypeScript 编译目标(target)设置 微软下一代Web前端技术Blazor(C#编译为WebAssembly) LinqPad的变量比较功能 Web后台技术趋势 MSBI - KPI 数据库的NULL值讨论 所有的列表都应该考虑排序 产品应该努力提高用户使用的方便性 上传和下载控制协议 Silverlight商业应用实例-新浪财经银光版 前台线程和后台线程的区别 笔记:如何让wpf中disabled的控件弹出右键菜单 - Jiger - 博客园 xaml数据绑定时字段不存在的错误处理方法 jQuery中bind函数绑定多个事件 StringFormat绑定语法中的问题 wpf/silverlight指定空值特殊显示的语法 jQuery的ajax函数中timeout参数的默认值 Visual Studio中Website和Web Application Project的区别 Silverlight 2.0 学习笔记王计平版-01-开始学习XAML
CSV文件的规范
Jiger · 2016-01-28 · via 博客园 - Jiger

CSV文件,全程Comma-separated values,就是逗号分隔的数据文件。常用于数据集成的数据交换部分标准部分。

最近看到一个项目组在讨论接口文件CSV的规范,真是替他们着急。讨论点:

  1. 文件是否有标题行(header row),一方坚持要有,接口另一方坚持不能有。
  2. 行分割符,一方坚持使用Unix style的0x0A字符,另一方坚持使用Windows/Dos风格的0x0D0x0A(或者说\r\n),回车换行两个字符。
  3. 列分隔符,一方坚持使用一个不可见字符0x05,说防止和内容字符串冲突,另一方坚持使用0x1B(ESC键)。
  4. 字符串中如果有换行怎么处理,也没有统一的意见。

不会Google真可怕,这个东西很简单,先看是否有标准,如果有严格按照标准走。如果没有标准,看是否有常见做法(或者叫事实标准)。Google一下关键字“CSV”,第一条就是维基百科(wikipedia)的解释。

An official standard for the CSV file format does not exist, but RFC 4180 provides a de facto standard for many aspects of it.
Jiger: CSV没有正式标准,但是国际互联网工程任务组(IETF)给推荐标准RFC 4180描述了CSV文件的结构。

下面一种常见配置:

  • MS-DOS-style lines that end with (CR/LF) characters (optional for the last line)
    Jiger: {使用回车换行(两个字符)作为行分隔符,最后一行数据可以没有这两个字符。}
  • An optional header record (there is no sure way to detect whether it is present, so care is required when importing).
    Jiger:{标题行是否需要,要双方显示约定}.
  • Each record "should" contain the same number of comma-separated fields.
    Jiger:{每行记录的字段数要相同,使用逗号分隔。} 逗号是默认使用的值,双方可以约定别的。
  • Any field may be quoted (with double quotes).
    Jiger:{任何字段的值都可以使用双引号括起来}. 为简单期间,可以要求都使用双引号。
  • Fields containing a line-break, double-quote, and/or commas should be quoted. (If they are not, the file will likely be impossible to process correctly).
    Jiger:{字段值中如果有换行符,双引号,逗号的,必须要使用双引号括起来。这是必须的。}
  • A (double) quote character in a field must be represented by two (double) quote characters.
    Jiger:{如果值中有双引号,使用一对双引号来表示原来的一个双引号}

如果使用了以上推荐标准,可以减少很多时间来讨论方案。

posted on 2016-01-28 03:11  Jiger  阅读(4162)  评论()    收藏  举报