FileCsvDocument Class |
Read a file with Read(String) (or Read(String, Boolean) to treat the first row as a column-name header), then query its dimensions (RowCount, ColumnCount), retrieve typed values by column and row with the TryGet methods — addressing columns by index or, when a header is present, by name — or enumerate its rows. To build a file, construct the document with a fixed column count, populate cells with the Set(Int32, Int32, String) overloads (addressed by column and row), then persist it with Save(String). Every row has the same number of columns; addressing a column outside that count throws.
Namespace: Rhino.FileIO
The FileCsvDocument type exposes the following members.
| Name | Description | |
|---|---|---|
| FileCsvDocument(Int32) |
Constructs a new, empty document with a fixed number of columns. Every row written
to the document has exactly this many fields. The document has no header row.
| |
| FileCsvDocument(String) |
Constructs a new, empty document with a header row of column names. The number of
columns is the number of names supplied, and the header is written ahead of the data
rows by Save(String). Columns can then be addressed by name (see
ColumnIndex(String) and the name-keyed TryGet overloads).
|
| Name | Description | |
|---|---|---|
| ColumnCount |
The number of columns in the document. Every row has exactly this many fields.
| |
| HasHeader |
True if the document has a header row of column names. See ColumnIndex(String).
| |
| Header |
The column names, or null if the document has no header. RowCount counts
only the data rows; the header is not one of them.
| |
| Item |
Gets the value of a cell, addressed by column and row. Use TryGetString(Int32, Int32, String)
for access that does not throw when the cell does not exist.
| |
| RowCount |
The number of rows in the document.
|
| Name | Description | |
|---|---|---|
| Clear |
Removes all rows from the document.
| |
| ColumnIndex |
Returns the zero-based index of the column with the given name (case-insensitive), or
-1 if the document has no header or no column with that name. When names are duplicated,
the first is returned.
| |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
| GetEnumerator |
Returns an enumerator that iterates over the committed rows of the document.
| |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetRow |
Returns the fields of a row.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| Read(String) |
Reads a CSV file from disk. The file is assumed to have no header row.
| |
| Read(TextReader) |
Reads CSV content from a text reader. The content is assumed to have no header row.
| |
| Read(String, Boolean) |
Reads a CSV file from disk.
| |
| Read(TextReader, Boolean) |
Reads CSV content from a text reader.
| |
| Save(String) |
Writes the document to a file on disk, encoded as UTF-8 with a byte order mark. The
mark lets spreadsheet applications (for example Excel on Windows and Mac) detect the
encoding rather than falling back to the system code page, which garbles non-ASCII
text such as Korean (RH-97173). Use Save(String, Encoding) with
new UTF8Encoding(false) to write UTF-8 without a mark.
| |
| Save(TextWriter) |
Writes the document to a text writer. Records are separated by CRLF, per RFC 4180. If
the document has a header, it is written ahead of the data rows.
| |
| Save(String, Encoding) |
Writes the document to a file on disk using the specified encoding.
| |
| Set(Int32, Point3d) |
Sets a row from a 3-D point. This is only valid when ColumnCount is 3:
the point's X, Y, and Z are written to columns 0, 1, and 2 with the general ("G")
format specifier and the invariant culture.
| |
| Set(Int32, Point3d, String) |
Sets a row from a 3-D point, using the specified .NET numeric format string. This is
only valid when ColumnCount is 3: the point's X, Y, and Z are written to
columns 0, 1, and 2 with the invariant culture.
| |
| Set(Int32, Int32, Boolean) |
Sets the value of a cell to a boolean, written as "1" (true) or "0" (false).
| |
| Set(Int32, Int32, DateTime) |
Sets the value of a cell to a date and time, formatted as a round-trip ISO 8601 string
(the "o" format) using the invariant culture.
| |
| Set(Int32, Int32, Double) |
Sets the value of a specific cell to a double-precision number, formatted with the
general ("G") format specifier and the invariant culture.
| |
| Set(Int32, Int32, Color) |
Sets the value of a cell to a color, stored as its 32-bit ARGB integer
(ToArgb), so that the alpha channel round-trips.
| |
| Set(Int32, Int32, Guid) |
Sets the value of a cell to a globally unique identifier, formatted with hyphens and
no braces (the "D" format, for example "11f820ff-952a-4b0b-b10a-59f82c2eb1f4").
| |
| Set(Int32, Int32, Int32) |
Sets the value of a specific cell to a 32-bit integer, formatted using the invariant culture.
| |
| Set(Int32, Int32, Int64) |
Sets the value of a specific cell to a 64-bit integer, formatted using the invariant culture.
| |
| Set(Int32, Int32, String) |
Sets the value of a cell, addressed by column and row. Rows are added as needed (any
intervening rows are created and filled with empty fields), but the column count is fixed.
| |
| Set(Int32, Int32, DateTime, String) |
Sets the value of a cell to a date and time, formatted with the specified .NET
date/time format string and the invariant culture.
| |
| Set(Int32, Int32, Double, String) |
Sets the value of a specific cell to a double-precision number, formatted with the
specified .NET numeric format string and the invariant culture.
| |
| Set(Int32, Int32, Double, LengthUnit, DistanceDisplayMode, Int32) |
Sets the value of a cell to a double-precision number, formatted with
FormatNumber(Double, LengthUnit, DistanceDisplayMode, Int32, Boolean).
The unit system name is never appended to the field.
| |
| Set(Int32, Int32, Double, UnitSystem, DistanceDisplayMode, Int32) |
Sets the value of a cell to a double-precision number, formatted with
FormatNumber(Double, UnitSystem, DistanceDisplayMode, Int32, Boolean).
The unit system name is never appended to the field.
| |
| SetRow(Int32, IEnumerableString) |
Sets the fields of a row, addressed by index, growing the document as needed (any
intervening rows are created and filled with empty fields). This is the row-level
counterpart to GetRow(Int32). The number of fields must equal
ColumnCount. A null field is stored as an empty field.
| |
| SetRow(Int32, String) |
Sets the fields of a row, addressed by index, growing the document as needed (any
intervening rows are created and filled with empty fields). This is the row-level
counterpart to GetRow(Int32). The number of fields must equal
ColumnCount. A null field is stored as an empty field.
| |
| ToString |
Returns the full CSV content of the document as a string.
(Overrides ObjectToString.) | |
| TryGetBool(Int32, Int32, Boolean) |
Retrieves the value of a cell as a boolean. Recognizes "true"/"false", "yes"/"no",
and "1"/"0" (case-insensitive, surrounding whitespace ignored).
| |
| TryGetBool(String, Int32, Boolean) |
Retrieves the value of a cell as a boolean, addressing the column by header name.
| |
| TryGetColor(Int32, Int32, Color) |
Retrieves the value of a cell as a color from its 32-bit ARGB integer
(FromArgb(Int32)), as written by Set(Int32, Int32, Color).
| |
| TryGetColor(String, Int32, Color) |
Retrieves the value of a cell as a color, addressing the column by header name.
| |
| TryGetDateTime(Int32, Int32, DateTime) |
Retrieves the value of a cell as a date and time, parsed with the invariant culture and
RoundtripKind (so ISO 8601 values, including those written
by Set(Int32, Int32, DateTime), round-trip).
| |
| TryGetDateTime(String, Int32, DateTime) |
Retrieves the value of a cell as a date and time, addressing the column by header name.
| |
| TryGetDouble(Int32, Int32, Double) |
Retrieves the value of a cell as a double-precision number. The cell is
evaluated with TryParseNumber(String, Double), so
command-line math expressions (for example "1/2") are supported.
| |
| TryGetDouble(String, Int32, Double) |
Retrieves the value of a cell as a double-precision number, addressing the column by header name.
| |
| TryGetGuid(Int32, Int32, Guid) |
Retrieves the value of a cell as a globally unique identifier. Accepts any of the
formats understood by TryParse(String, Guid) (with or without
hyphens or braces).
| |
| TryGetGuid(String, Int32, Guid) |
Retrieves the value of a cell as a globally unique identifier, addressing the column by header name.
| |
| TryGetInt(Int32, Int32, Int32) |
Retrieves the value of a cell as a 32-bit integer, parsed using the invariant culture.
| |
| TryGetInt(String, Int32, Int32) |
Retrieves the value of a cell as a 32-bit integer, addressing the column by header name.
| |
| TryGetLong(Int32, Int32, Int64) |
Retrieves the value of a cell as a 64-bit integer, parsed using the invariant culture.
| |
| TryGetLong(String, Int32, Int64) |
Retrieves the value of a cell as a 64-bit integer, addressing the column by header name.
| |
| TryGetPoint |
Retrieves a row as a 3-D point. This succeeds only when ColumnCount is 3:
the row's three fields are joined and passed to
TryParse(String, Point3d).
| |
| TryGetString(Int32, Int32, String) |
Retrieves the value of a cell as a string.
| |
| TryGetString(String, Int32, String) |
Retrieves the value of a cell as a string, addressing the column by header name.
|