Changeset 12175

Show
Ignore:
Timestamp:
09/17/07 14:52:27 (1 year ago)
Author:
mloskot
Message:

Ported patch with date & time support to branches/1.4 (Ticket #1761).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/ogr/ogrsf_frmts/csv/drv_csv.html

    r9334 r12175  
    88<h1>Comma Separated Value (.csv)</h1> 
    99 
    10 OGR supports reading and writing non-spatial tabular data stored in 
     10<p>OGR supports reading and writing non-spatial tabular data stored in 
    1111text CSV files.  CSV files are a common interchange format between  
    1212software packages supporting tabular data and are also easily produced 
    13 manually with a text editor or with end-user written scripts or programs.<p> 
     13manually with a text editor or with end-user written scripts or programs.</p> 
    1414 
    15 While in theory .csv files could have any extension, in order to 
     15<p>While in theory .csv files could have any extension, in order to 
    1616auto-recognise the format OGR only supports CSV files ending with the 
    1717extention ".csv".  The datasource name may be either a single CSV file 
    1818or to a directory.  For a directory to be recognised as a .csv datasource 
    1919at 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> 
     20One layer (table) is produced from each .csv file accessed.</p> 
    2121 
    22 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 
     22<p>The OGR CSV driver supports reading and writing. Because the CSV format  
     23has variable length text lines, reading is done sequentially. Reading  
     24features in random order will generally be very slow. OGR CSV layer never 
    2525have any geometry on features, nor do they have an associated coordinate 
    26 system. The OGR CSV driver returns all attribute columns with a type of 
     26system. The OGR CSV driver returns all attribute columns with a type of 
    2727string if no field type information file (with .csvt extension) is 
    28 available.<p> 
     28available.</p> 
    2929 
    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 types 
    35 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 
     32through a descriptive file with same name as the CSV file, but .csvt extension. 
     33In a single line the types for each column have to be listed: double quoted and 
     34comma separated (e.g., "Integer","String"). The driver will then use these types 
     35as specified for the csv columns.</p> 
    3636 
    3737<h2>Format</h2> 
    3838 
    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 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> 
     39<p>CSV files have one line for each feature (record) in the layer (table).   
     40The attribute field values are separated by commas. At least two fields 
     41per line must be present. Lines may be terminated by a DOS (CR/LF) or 
     42Unix (LF) style line terminators. Each record should have the same number 
     43of fields.</p> 
    4444 
    45 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> 
     45<p>Complex attribute values (such as those containing commas, quotes or newlines)  
     46may be placed in double quotes. Any occurances of double quotes within  
     47the quoted string should be doubled up to "escape" them.</p> 
    4848 
    49 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  
     49<p>The driver attempts to treat the first line of the file as a list of field  
     50names for all the fields. However, if one or more of the names is all  
    5151numeric it is assumed that the first line is actually data values and 
    5252dummy field names are generated internally (field_1 through field_n) and 
    53 the first record is treated as a feature. <p> 
     53the first record is treated as a feature.</p> 
    5454 
    5555Example (employee.csv): 
     
    6060</pre> 
    6161 
    62 Note that the Comments value for the first data record is placed in  
     62<p>Note that the Comments value for the first data record is placed in  
    6363double quotes because the value contains quotes, and those quotes have 
    6464to be doubled up so we know we haven't reached the end of the quoted string 
    65 yet. <p> 
     65yet.</p> 
    6666 
    67 Many variations of textual input are sometimes called Comma Separated 
     67<p>Many variations of textual input are sometimes called Comma Separated 
    6868Value files, including files without commas, but fixed column widths, 
    6969those using tabs as seperators or those with other auxilary data defining 
    70 field types or structure. This driver does not attempt to support all  
     70field types or structure. This driver does not attempt to support all  
    7171such files, but instead to support simple .csv files that can be  
    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> 
     72auto-recognised. Scripts or other mechanisms can generally be used to convert 
     73other variations into a form that is compatible with the OGR CSV driver.</p> 
    7474 
    7575<h2>Creation Issues</h2> 
    7676 
    77 The driver supports creating new databases (as a directory 
     77<p>The driver supports creating new databases (as a directory 
    7878of .csv files), adding new .csv files to an existing directory or .csv 
    79 files or appending features to an existing .csv table. Deleting or 
    80 replacing existing features is not supported.<p> 
     79files or appending features to an existing .csv table. Deleting or 
     80replacing existing features is not supported.</p> 
    8181 
    82 Creation options: 
     82<p>Creation options: 
    8383 
    8484<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 
    8886termination conventions of the local platform (CR/LF on win32 or  
    8987LF on all other systems).  This may be overridden through use of the 
    9088LINEFORMAT 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> 
    9390</ul> 
     91</p> 
    9492 
    9593<h2>Other Notes</h2> 
     94 
     95<p> 
    9696<ul> 
    97 <li> Development of the OGR CSV driver was supported by  
     97<li>Development of the OGR CSV driver was supported by  
    9898<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>. 
    100100</ul> 
     101</p> 
    101102 
    102103</body> 
  • branches/1.4/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp

    r10646 r12175  
    170170            else if (EQUAL(papszFieldTypes[iField], "String")) 
    171171                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);  
    172178        } 
    173179