Changeset 12175
- Timestamp:
- 09/17/07 14:52:27 (1 year ago)
- Files:
-
- branches/1.4/gdal/ogr/ogrsf_frmts/csv/drv_csv.html (modified) (2 diffs)
- branches/1.4/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/gdal/ogr/ogrsf_frmts/csv/drv_csv.html
r9334 r12175 8 8 <h1>Comma Separated Value (.csv)</h1> 9 9 10 OGR supports reading and writing non-spatial tabular data stored in10 <p>OGR supports reading and writing non-spatial tabular data stored in 11 11 text CSV files. CSV files are a common interchange format between 12 12 software packages supporting tabular data and are also easily produced 13 manually with a text editor or with end-user written scripts or programs.< p>13 manually with a text editor or with end-user written scripts or programs.</p> 14 14 15 While in theory .csv files could have any extension, in order to15 <p>While in theory .csv files could have any extension, in order to 16 16 auto-recognise the format OGR only supports CSV files ending with the 17 17 extention ".csv". The datasource name may be either a single CSV file 18 18 or to a directory. For a directory to be recognised as a .csv datasource 19 19 at least half the files in the directory need to have the extension .csv. 20 One layer (table) is produced from each .csv file accessed.< p>20 One layer (table) is produced from each .csv file accessed.</p> 21 21 22 The OGR CSV driver supports reading and writing.Because the CSV format23 has variable length text lines, reading is done sequentially. Reading24 features in random order will generally be very slow. OGR CSV layer never22 <p>The OGR CSV driver supports reading and writing. Because the CSV format 23 has variable length text lines, reading is done sequentially. Reading 24 features in random order will generally be very slow. OGR CSV layer never 25 25 have any geometry on features, nor do they have an associated coordinate 26 system. The OGR CSV driver returns all attribute columns with atype of26 system. The OGR CSV driver returns all attribute columns with a type of 27 27 string if no field type information file (with .csvt extension) is 28 available.< p>28 available.</p> 29 29 30 Limited type recognition can be done for Integer, Real and String 31 columns through a descriptive file with same name as the CSV file, 32 but .csvt extension. In a single line the types for each column 33 have to be listed: double quoted and comma 34 separated (e.g., "Integer","String"). The driver will then use these types35 as specified for the csv columns.< p>30 <p>Limited type recognition can be done for Integer, Real, String, Date 31 (YYYY-MM-DD), Time (HH:MM:SS+nn) and DateTime (YYYY-MM-DD HH:MM:SS+nn) columns 32 through a descriptive file with same name as the CSV file, but .csvt extension. 33 In a single line the types for each column have to be listed: double quoted and 34 comma separated (e.g., "Integer","String"). The driver will then use these types 35 as specified for the csv columns.</p> 36 36 37 37 <h2>Format</h2> 38 38 39 CSV files have one line for each feature (record) in the layer (table).40 The attribute field values are separated by commas. At least two fields41 per line must be present. Lines may be terminated by a DOS (CR/LF) or42 Unix (LF) style line terminators. Each record should have the same number43 of fields.< p>39 <p>CSV files have one line for each feature (record) in the layer (table). 40 The attribute field values are separated by commas. At least two fields 41 per line must be present. Lines may be terminated by a DOS (CR/LF) or 42 Unix (LF) style line terminators. Each record should have the same number 43 of fields.</p> 44 44 45 Complex attribute values (such as those containing commas, quotes or newlines)46 may be placed in double quotes. Any occurances of double quotes within47 the quoted string should be doubled up to "escape" them.< p>45 <p>Complex attribute values (such as those containing commas, quotes or newlines) 46 may be placed in double quotes. Any occurances of double quotes within 47 the quoted string should be doubled up to "escape" them.</p> 48 48 49 The driver attempts to treat the first line of the file as a list of field50 names for all the fields. However, if one or more of the names is all49 <p>The driver attempts to treat the first line of the file as a list of field 50 names for all the fields. However, if one or more of the names is all 51 51 numeric it is assumed that the first line is actually data values and 52 52 dummy field names are generated internally (field_1 through field_n) and 53 the first record is treated as a feature. <p>53 the first record is treated as a feature.</p> 54 54 55 55 Example (employee.csv): … … 60 60 </pre> 61 61 62 Note that the Comments value for the first data record is placed in62 <p>Note that the Comments value for the first data record is placed in 63 63 double quotes because the value contains quotes, and those quotes have 64 64 to be doubled up so we know we haven't reached the end of the quoted string 65 yet. <p>65 yet.</p> 66 66 67 Many variations of textual input are sometimes called Comma Separated67 <p>Many variations of textual input are sometimes called Comma Separated 68 68 Value files, including files without commas, but fixed column widths, 69 69 those using tabs as seperators or those with other auxilary data defining 70 field types or structure. This driver does not attempt to support all70 field types or structure. This driver does not attempt to support all 71 71 such files, but instead to support simple .csv files that can be 72 auto-recognised. Scripts or other mechanisms can generally be used to convert73 other variations into a form that is compatible with the OGR CSV driver. <p>72 auto-recognised. Scripts or other mechanisms can generally be used to convert 73 other variations into a form that is compatible with the OGR CSV driver.</p> 74 74 75 75 <h2>Creation Issues</h2> 76 76 77 The driver supports creating new databases (as a directory77 <p>The driver supports creating new databases (as a directory 78 78 of .csv files), adding new .csv files to an existing directory or .csv 79 files or appending features to an existing .csv table. Deleting or80 replacing existing features is not supported.< p>79 files or appending features to an existing .csv table. Deleting or 80 replacing existing features is not supported.</p> 81 81 82 Creation options:82 <p>Creation options: 83 83 84 84 <ul> 85 86 <li> <b>LINEFORMAT</b>: 87 By default when creating new .csv files they are created with the line 85 <li><b>LINEFORMAT</b>: By default when creating new .csv files they are created with the line 88 86 termination conventions of the local platform (CR/LF on win32 or 89 87 LF on all other systems). This may be overridden through use of the 90 88 LINEFORMAT layer creation option which may have a value of <b>CRLF</b> 91 (DOS format) or <b>LF</b> (Unix format). <p> 92 89 (DOS format) or <b>LF</b> (Unix format).</li> 93 90 </ul> 91 </p> 94 92 95 93 <h2>Other Notes</h2> 94 95 <p> 96 96 <ul> 97 <li> Development of the OGR CSV driver was supported by97 <li>Development of the OGR CSV driver was supported by 98 98 <a href="http://www.dmsolutions.ca/">DM Solutions Group</a> and 99 <a href="http://www.gomoos.org/">GoMOOS</a>. <p>99 <a href="http://www.gomoos.org/">GoMOOS</a>. 100 100 </ul> 101 </p> 101 102 102 103 </body> branches/1.4/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp
r10646 r12175 170 170 else if (EQUAL(papszFieldTypes[iField], "String")) 171 171 oField.SetType(OFTString); 172 else if (EQUAL(papszFieldTypes[iField], "Date")) 173 oField.SetType(OFTDate); 174 else if (EQUAL(papszFieldTypes[iField], "Time")) 175 oField.SetType(OFTTime); 176 else if (EQUAL(papszFieldTypes[iField], "DateTime")) 177 oField.SetType(OFTDateTime); 172 178 } 173 179
