CSVファイルの一般的な書式

広告

広告

原文

最終更新
2006-09-20T23:56:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/rfc4180.html#source

CSVファイルの一般的な書式(和訳)

最終更新
2006-09-21T02:16:00+09:00
この記事のURI参照
https://www.7key.jp/rfc/rfc2318.html#translation

Status of this Memo

   This memo provides information for the Internet community.  It does
   not specify an Internet standard of any kind.  Distribution of this
   memo is unlimited.

当メモはインターネットコミュニティに役立つであろう情報を提供するものであり、これによって標準的なインターネット像をでっちあげようとするものではない。また、当メモは配布に関しての制限を設けていない。

Copyright Notice

   Copyright (C) The Internet Society (2005).

Abstract

   This RFC documents the format used for Comma-Separated Values (CSV)
   files and registers the associated MIME type "text/csv".

当文書はCSVファイルに用いられる書式について定義し、関連付けられるMIMEタイプ(text/css)を登記するものである。

Table of Contents

   1. Introduction ....................................................2
   2. Definition of the CSV Format ....................................2
   3. MIME Type Registration of text/csv ..............................4
   4. IANA Considerations .............................................5
   5. Security Considerations .........................................5
   6. Acknowledgments .................................................6
   7. References ......................................................6
      7.1. Normative References .......................................6
      7.2. Informative References .....................................6

1. Introduction

   The comma separated values format (CSV) has been used for exchanging
   and converting data between various spreadsheet programs for quite
   some time.  Surprisingly, while this format is very common, it has
   never been formally documented.  Additionally, while the IANA MIME
   registration tree includes a registration for
   "text/tab-separated-values" type, no MIME types have ever been
   registered with IANA for CSV.  At the same time, various programs and
   operating systems have begun to use different MIME types for this
   format.  This RFC documents the format of comma separated values
   (CSV) files and formally registers the "text/csv" MIME type for CSV
   in accordance with RFC 2048 [1].

CSV形式は、様々な表計算プログラム間でのデータの交換或いは変換の際に極めて頻繁に利用されてきた。にも関らず、CSVファイルの形式が公式に文書化されたことは今までなく、更にはIANAのMIME登録ツリーにCSVに関するMIMEタイプは未登録――"text/tab-separated-values"は登録されているのに――のままである。このため、様々なプログラムやOSがこの形式に対して異なるMIMEタイプを使い始めているのが現状だ。当文書はCSVファイルに用いられる書式を定義し、関連付けられるMIMEタイプ(text/css)をRFC2048[1]の通り登記するものである。

2. Definition of the CSV Format

   While there are various specifications and implementations for the
   CSV format (for ex. [4], [5], [6] and [7]), there is no formal
   specification in existence, which allows for a wide variety of
   interpretations of CSV files.  This section documents the format that
   seems to be followed by most implementations:

CSV形式の仕様と実装は多岐に渡る(7.2.参考文献[4]、[5]、[6]、[7])が、多様な実装が解釈し得るCSV形式の公式な仕様はない。本節で、殆どの実装が解釈可能なCSV形式の書式を述べる。

   1.  Each record is located on a separate line, delimited by a line
       break (CRLF).  For example:

       aaa,bbb,ccc CRLF
       zzz,yyy,xxx CRLF

各レコードは改行コード(CRLF)を区切りとし、即ち行として配置される。

   2.  The last record in the file may or may not have an ending line
       break.  For example:

       aaa,bbb,ccc CRLF
       zzz,yyy,xxx

ファイル内最終レコードの末尾には改行コードがあってもよいし、なくてもよい。

   3.  There maybe an optional header line appearing as the first line
       of the file with the same format as normal record lines.  This
       header will contain names corresponding to the fields in the file
       and should contain the same number of fields as the records in
       the rest of the file (the presence or absence of the header line
       should be indicated via the optional "header" parameter of this
       MIME type).  For example:

       field_name,field_name,field_name CRLF
       aaa,bbb,ccc CRLF
       zzz,yyy,xxx CRLF

ファイルの先頭に、通常レコードと同一の書式をとるヘッダ行があってもよい。ヘッダではレコードの各フィールド名称を明示し、各レコードと同数のフィールドを持つべきである。ヘッダ行の有無は、MIMEタイプの任意パラメータであるheaderで明らかにすべきだ。

   4.  Within the header and each record, there may be one or more
       fields, separated by commas.  Each line should contain the same
       number of fields throughout the file.  Spaces are considered part
       of a field and should not be ignored.  The last field in the
       record must not be followed by a comma.  For example:

       aaa,bbb,ccc

ヘッダ及び各レコードは、カンマで区切られた一つ以上のフィールドからなる。同じファイル内の中では、それぞれの行が持つフィールド数を統一すべきである。空白はフィールドの一部と見做し、無視すべきではない。また、各レコードの最終フィールドの更に後にカンマをつけてはならない。

   5.  Each field may or may not be enclosed in double quotes (however
       some programs, such as Microsoft Excel, do not use double quotes
       at all).  If fields are not enclosed with double quotes, then
       double quotes may not appear inside the fields.  For example:

       "aaa","bbb","ccc" CRLF
       zzz,yyy,xxx

ダブルクオーテーションでそれぞれのフィールドを括ってもよい(括らなくともよい)。Microsoft Excelのようにダブルクォーテーションを全く用いないプログラムも中にはある。ただし、フィールドがダブルクォーテーションで括られていない場合はその値にダブルクォーテーションを含んではならない。

   6.  Fields containing line breaks (CRLF), double quotes, and commas
       should be enclosed in double-quotes.  For example:

       "aaa","b CRLF
       bb","ccc" CRLF
       zzz,yyy,xxx

改行コード(CRLF)、ダブルクオーテーション、カンマを含むフィールドはダブルクォーテーションで括るべきだ。

   7.  If double-quotes are used to enclose fields, then a double-quote
       appearing inside a field must be escaped by preceding it with
       another double quote.  For example:

       "aaa","b""bb","ccc"

フィールド内にダブルクォーテーションを含む場合は、ダブルクォーテーションでエスケープしなければならない。

   The ABNF grammar [2] appears as follows:

   file = [header CRLF] record *(CRLF record) [CRLF]

   header = name *(COMMA name)

   record = field *(COMMA field)

   name = field

   field = (escaped / non-escaped)

   escaped = DQUOTE *(TEXTDATA / COMMA / CR / LF / 2DQUOTE) DQUOTE

   non-escaped = *TEXTDATA

   COMMA = %x2C

   CR = %x0D ;as per section 6.1 of RFC 2234 [2]

   DQUOTE =  %x22 ;as per section 6.1 of RFC 2234 [2]

   LF = %x0A ;as per section 6.1 of RFC 2234 [2]

   CRLF = CR LF ;as per section 6.1 of RFC 2234 [2]

   TEXTDATA =  %x20-21 / %x23-2B / %x2D-7E

ABNF表記[2]は次の通り。

3. MIME Type Registration of text/csv

   This section provides the media-type registration application (as per
   RFC 2048 [1].

   To: ietf-types@iana.org

   Subject: Registration of MIME media type text/csv

   MIME media type name: text

   MIME subtype name: csv

   Required parameters: none
Optional parameters: charset, header

本節ではRFC2048[1]に従ったメディアタイプの登録申請を提供する。

      Common usage of CSV is US-ASCII, but other character sets defined
      by IANA for the "text" tree may be used in conjunction with the
      "charset" parameter.

      The "header" parameter indicates the presence or absence of the
      header line.  Valid values are "present" or "absent".
      Implementors choosing not to use this parameter must make their
      own decisions as to whether the header line is present or absent.

CSVでは一般にUS-ASCIIを用いるが、IANAの文字ツリーで定義されている他の文字セットであればcharsetパラメータで指定の上用いてもよい。

headerパラメータはヘッダ行の有無を明示するパラメータで、有効な値はpresent(ヘッダ行あり)とabsent(ヘッダ行なし)である。このパラメータを使用しないのであれば、ヘッダ行の有無は実装者自身が判断しなければならない。

Encoding considerations:

      As per section 4.1.1. of RFC 2046 [3], this media type uses CRLF
      to denote line breaks.  However, implementors should be aware that
      some implementations may use other values.

RFC2046[3]の4.1.1節にある通り、このメディアタイプでは改行コードにCRLFを用いる。ただし、実装者は他の改行コードが用いられる実装があることも考慮にいれるべきである。

Security considerations:

      CSV files contain passive text data that should not pose any
      risks.  However, it is possible in theory that malicious binary
      data may be included in order to exploit potential buffer overruns
      in the program processing CSV data.  Additionally, private data
      may be shared via this format (which of course applies to any text
      data).

CSVファイルの中身は、何らリスクを生まない静的なテキストデータである。ただし、CSVデータを処理するプログラムでバッファオーバランを発生させるような悪意あるバイナリデータが含まれることは想定し得る。更には個人情報がCSV形式――もちろんこれは全てのテキストデータに言えることだが――で共有されるかもしれない。

Interoperability considerations:

      Due to lack of a single specification, there are considerable
      differences among implementations.  Implementors should "be
      conservative in what you do, be liberal in what you accept from
      others" (RFC 793 [8]) when processing CSV files.  An attempt at a
      common definition can be found in Section 2.

      Implementations deciding not to use the optional "header"
      parameter must make their own decision as to whether the header is
      absent or present.

統一の仕様がなかったために、それぞれの実装の間には考慮すべき違いがある。実装者はCSVファイルを処理する際、自身が何かをする際は保守的に、他者を受け入れる際は革新的に(RFC793[8])との理念に沿って行動すべきである。一般的な仕様への考察は2節を参照のこと。

headerパラメータを使用しないのであれば、ヘッダ行の有無は実装自身が判断しなければならない。

Published specification:

      While numerous private specifications exist for various programs
      and systems, there is no single "master" specification for this
      format.  An attempt at a common definition can be found in Section
      2.

様々なプログラムやシステム向けの独自実装は多いが、統一された正当な仕様は存在しない。一般的な仕様への考察は2節を参照のこと。

Applications that use this media type:

      Spreadsheet programs and various data conversion utilities

表計算ソフトや様々なデータ変換ツール。

Additional information:

      Magic number(s): none

      File extension(s): CSV

      Macintosh File Type Code(s): TEXT
   Person & email address to contact for further information:

      Yakov Shafranovich <ietf@shaftek.org>

   Intended usage: COMMON

   Author/Change controller: IESG

4. IANA Considerations

   The IANA has registered the MIME type "text/csv" using the
   application provided in Section 3 of this document.

IANAは、MIMEタイプ"text/csv"を当文書3節の申請により登録した。

5. Security Considerations

   See discussion above in section 3.

安全性の考察を参照のこと。

6. Acknowledgments

   The author would like to thank Dave Crocker, Martin Duerst, Joel M.
   Halpern, Clyde Ingram, Graham Klyne, Bruce Lilly, Chris Lilley, and
   members of the IESG for their helpful suggestions.  A special word of
   thanks goes to Dave for helping with the ABNF grammar.

Dave Crocker氏、Martin Duerst氏、Joel M.Halpern氏、Clyde Ingram氏、Graham Klyne氏、Bruce Lilly氏、Chris Lilley氏、また力を貸してくれたIESGの方々に感謝する。特にABNF文法の件でご助力頂いたDave Crocker氏には感謝の言葉もない。

   The author would also like to thank Henrik Lefkowetz, Marshall Rose,
   and the folks at xml.resource.org for providing many of the tools
   used for preparing RFCs and Internet drafts.

更に、Henrik Lefkowetz氏、Marshall Rose氏、またxml.resource.orgにてRFC及びインターネットドラフトの準備に用いる多くのツールを提供してくれた方々に感謝する。

   A special thank you goes to L.T.S.

7. References

7.1. Normative References

   [1]  Freed, N., Klensin, J., and J. Postel, "Multipurpose Internet
        Mail Extensions (MIME) Part Four: Registration Procedures", BCP
        13, RFC 2048, November 1996.

   [2]  Crocker, D. and P. Overell, "Augmented BNF for Syntax
        Specifications: ABNF", RFC 2234, November 1997.

   [3]  Freed, N. and N. Borenstein, "Multipurpose Internet Mail
        Extensions (MIME) Part Two: Media Types", RFC 2046, November
        1996.

7.2. Informative References

   [4]  Repici, J., "HOW-TO: The Comma Separated Value (CSV) File
        Format", 2004,
        <http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm>.

   [5]  Edoceo, Inc., "CSV Standard File Format", 2004,
        <http://www.edoceo.com/utilis/csv-file-format.php>.

   [6]  Rodger, R. and O. Shanaghy, "Documentation for Ricebridge CSV
        Manager", February 2005,
        <http://www.ricebridge.com/products/csvman/reference.htm>.

   [7]  Raymond, E., "The Art of Unix Programming, Chapter 5", September
        2003,
        <http://www.catb.org/~esr/writings/taoup/html/ch05s02.html>.

   [8]  Postel, J., "Transmission Control Protocol", STD 7, RFC 793,
        September 1981.

Author's Address

   Yakov Shafranovich
   SolidMatrix Technologies, Inc.

   EMail: ietf@shaftek.org
   URI:   http://www.shaftek.org
   Copyright (C) The Internet Society (2005).
   This document is subject to the rights, licenses and restrictions
   contained in BCP 78, and except as set forth therein, the authors
   retain all their rights.

当文書はBCP78で触れられている権利と許可と制限の適用を受け、文書中で明らかにされている個所を除いて著者が全ての権利を維持する。

   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
   ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
   INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

当文書及び文書内の情報は無保証で提供され、寄稿者、寄稿者が代表となる組織、もしあれば寄稿者を後援する組織、インターネット学会及びIETFは、当文書がいかなる権利も侵害していないという保証、商業利用や特定目的に対する適合性への保証、更にはこれらに限らずあらゆる保証について明示的にも暗黙的にも保証をしていない。

Intellectual Property

   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in BCP 78 and BCP 79.

IETFは当文書で提供する技術の実装や他の技術の使用に対して主張される知的所有権、その他の権利や効力または適用範囲、更にそれらの権利に基づく全てのライセンスが利用可能であるか否かについては一切関与をしない。これらに関して全ての権利が明確となるよう調査が行われているわけではない。文書の権利に関るIETFの手続きについてはBCP78とBCP79で閲覧可能である。

   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   http://www.ietf.org/ipr.

IETFによるIPR開示情報のコピーや利用可能なライセンスの保証、本仕様の実装者やユーザがそれらの一般ライセンスや使用許諾を得るための手順は、IETFのオンラインIPRレポジトリから入手可能である。

   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at
   ietf-ipr@ietf.org.

IETFは本標準を実装するために必要な技術に関する著作権、特許、特許出願、その他の知的所有権への指摘を歓迎する。その折は、ietf-ipr@ietf.org まで情報をお寄せ頂きたい。

Acknowledgement

   Funding for the RFC Editor function is provided by the IETF
   Administrative Support Activity (IASA).

RFC編集者の職務に対する資金供給は、現在インターネット学会から提供されている。

広告

Copyright (C) 2006 七鍵 key@do.ai 初版:2006年09月19日 最終更新:2006年09月21日