CSV Introduction
What is CSV? Everyone has heard of it, but I guess very few people can explain it in a comprehensive way, then the younger brother will caught dead a little bit. CSV I understand a file that stores data, which is stored in a comma as a partition (or, of course, with tabs).
Rules for CSV
1 The opening is not left empty to the behavior unit.
2 can contain or do not contain column name, including column name in the first line of the file.
31 rows of data do not span rows, no blank lines.
4 A comma (that is,) is used as a delimiter, the column is empty also to express its existence.
5 column Contents If there is a half-width quotation mark (that is, "), replace with a half-width double quotation mark (" ") escape, that is, use the half-width quotation mark (" ") to enclose the field value.
6 file read-write quotation marks, comma operation rules are mutually inverse.
7 Internal code format is not limited, can be ASCII, Unicode or other.
8 special characters are not supported
Python csv
The CSV module is built into Python and can be used directly by import CSV
The usual methods are as follows:
Writer, Dictwriter, reader, Dictreader
I should not explain, I do not know to check the meaning of English ... The dict is read and written by means of a dictionary.
Code Combat
How to obtain the source code please see the video
This article is from the "Cockroach Performance automation test brand" blog, please be sure to keep this source http://xqtesting.blog.51cto.com/4626073/1975472
Python reads and writes CSV files in real combat