CSV 格式及注意事项
来源:互联网 发布:网络收音机软件哪个好 编辑:程序博客网 时间:2024/04/30 06:03
CSV is a delimited data format that has fields/columns separated by the comma character and records/rows separated by newlines. Fields that contain a special character (comma, newline, or double quote), must be enclosed in double quotes. However, if a line contains a single entry which is the empty string, it may be enclosed in double quotes. If a field's value contains a double quote character it is escaped by placing another double quote character next to it. The CSV file format does not require a specific character encoding, byte order, or line terminator format.
- Each record is one line terminated by a line feed (ASCII/LF=0x0A) or a carriage return and line feed pair (ASCII/CRLF=0x0D 0x0A), however, line-breaks can be embedded.
- Fields are separated by commas.
1997,Ford,E350
- In some CSV implementations, leading and trailing spaces or tabs, adjacent to commas, are trimmed. This practice is contentious and in fact is specifically prohibited by RFC 4180, which states, "Spaces are considered part of a field and should not be ignored."
1997, Ford , E350
same as
1997,Ford,E350
- Fields with embedded commas must be delimited with double-quote characters.
1997,Ford,E350,"Super, luxurious truck"
- Fields with embedded double-quote characters must be delimited with double-quote characters, and the embedded double-quote characters must be represented by a pair of double-quote characters.
1997,Ford,E350,"Super ""luxurious"" truck"
- Fields with embedded line breaks must be delimited by double-quote characters.
1997,Ford,E350,"Go get one now
they are going fast"
- Fields with leading or trailing spaces must be delimited by double-quote characters. (See comment about leading and trailing spaces above.)
1997,Ford,E350," Super luxurious truck "
- Fields may always be delimited by double-quote characters, whether necessary or not.
"1997","Ford","E350"
- The first record in a csv file may contain column names in each of the fields.
Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar
[edit] Example
1997 Ford E350 ac, abs, moon 3000.00 1999 Chevy Venture "Extended Edition" 4900.00 1996 Jeep Grand Cherokee MUST SELL! air, moon roof, loaded 4799.00
The above table of data may be represented in CSV format as follows:
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
This CSV example illustrates that:
- fields that contain commas, double-quotes, or line-breaks must be quoted,
- a quote within a field must be escaped with an additional quote immediately preceding the literal quote,
- space before and after delimiter commas may be trimmed, and
- a line break within an element must be preserved.
- CSV 格式及注意事项
- CSV格式
- xml 的基本格式 及 注意事项
- scanf函数中的格式字符串及注意事项
- sqlite import csv注意事项
- Linux环境下sendmail发送html格式正文及csv格式附件邮件
- CSV格式规范
- 导出CSV格式
- 数据库文件导出csv格式
- CSV标准格式
- 标准CSV格式
- CSV的格式
- CSV格式读写
- php 导入csv格式
- csv转Libsvm格式
- 导出csv 格式
- mysqldump 倒出 csv格式
- csv格式转换xls
- 一些3D演示程序
- 流的下游复制更简单
- 怀孕 结婚
- Javascript各类型值之间的转换
- Asteroids的j2me版
- CSV 格式及注意事项
- 什么是中间件
- 关于项目管理的一点杂感
- echo 'names';
- echo 'names';
- 如何把从数据库读出来的数据以excel格式显示到网页?
- one
- 如何正确选择服务器证书
- windows注册表命令大全