📄 drv_csv.html
字号:
<html><head><title>Comma Separated Value (.csv)</title></head><body bgcolor="#ffffff"><h1>Comma Separated Value (.csv)</h1>OGR supports reading and writing non-spatial tabular data stored intext CSV files. CSV files are a common interchange format between software packages supporting tabular data and are also easily producedmanually with a text editor or with end-user written scripts or programs.<p>While in theory .csv files could have any extension, in order toauto-recognise the format OGR only supports CSV files ending with theextention ".csv". The datasource name may be either a single CSV fileor to a directory. For a directory to be recognised as a .csv datasourceat least half the files in the directory need to have the extension .csv.One layer (table) is produced from each .csv file accessed.<p>The OGR CSV driver supports reading and writing. Because the CSV format has variable length text lines, reading is done sequentially. Reading features in random order will generally be very slow. OGR CSV layer neverhave any geometry on features, nor do they have an associated coordinatesystem. The OGR CSV driver returns all attribute columns with a type ofstring if no field type information file (with .csvt extension) isavailable.<p>Limited type recognition can be done for Integer, Real and Stringcolumns through a descriptive file with same name as the CSV file,but .csvt extension. In a single line the types for each columnhave to be listed: double quoted and commaseparated (e.g., "Integer","String"). The driver will then use these typesas specified for the csv columns.<p><h2>Format</h2>CSV files have one line for each feature (record) in the layer (table). The attribute field values are separated by commas. At least two fieldsper line must be present. Lines may be terminated by a DOS (CR/LF) orUnix (LF) style line terminators. Each record should have the same numberof fields.<p>Complex attribute values (such as those containing commas, quotes or newlines) may be placed in double quotes. Any occurances of double quotes within the quoted string should be doubled up to "escape" them.<p>The driver attempts to treat the first line of the file as a list of field names for all the fields. However, if one or more of the names is all numeric it is assumed that the first line is actually data values anddummy field names are generated internally (field_1 through field_n) andthe first record is treated as a feature. <p>Example (employee.csv):<pre>ID,Salary,Name,Comments132,55000.0,John Walker,"The ""big"" cheese."133,11000.0,Jane Lake,Cleaning Staff</pre>Note that the Comments value for the first data record is placed in double quotes because the value contains quotes, and those quotes haveto be doubled up so we know we haven't reached the end of the quoted stringyet. <p>Many variations of textual input are sometimes called Comma SeparatedValue files, including files without commas, but fixed column widths,those using tabs as seperators or those with other auxilary data definingfield types or structure. This driver does not attempt to support all such files, but instead to support simple .csv files that can be auto-recognised. Scripts or other mechanisms can generally be used to convertother variations into a form that is compatible with the OGR CSV driver. <p><h2>Creation Issues</h2>The driver supports creating new databases (as a directoryof .csv files), adding new .csv files to an existing directory or .csvfiles or appending features to an existing .csv table. Deleting orreplacing existing features is not supported.<p>Creation options:<ul><li> <b>LINEFORMAT</b>:By default when creating new .csv files they are created with the linetermination conventions of the local platform (CR/LF on win32 or LF on all other systems). This may be overridden through use of theLINEFORMAT layer creation option which may have a value of <b>CRLF</b>(DOS format) or <b>LF</b> (Unix format). <p></ul><h2>Other Notes</h2><ul><li> Development of the OGR CSV driver was supported by <a href="http://www.dmsolutions.ca/">DM Solutions Group</a> and <a href="http://www.gomoos.org/">GoMOOS</a>.<p></ul></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -