# FileCsvDocument class

Namespace: [Rhino.FileIO](https://developer.rhino3d.com/api/rhinocommon/namespace/rhino.fileio.md) · Assembly: [RhinoCommon](https://developer.rhino3d.com/api/rhinocommon/assembly/rhinocommon.md) · Since v9.0

```cs
public class FileCsvDocument : IEnumerable<string[]>
```

A simple, general-purpose, in-memory representation of a [RFC 4180](https://www.ietf.org/rfc/rfc4180.txt)-compliant comma-separated value (CSV) file.

Read a file with [FileCsvDocument.Read(string)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/read.md) (or [FileCsvDocument.Read(string, bool)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/read.md) to treat the first row as a column-name header), then query its dimensions ([FileCsvDocument.RowCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/rowcount.md), [FileCsvDocument.ColumnCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columncount.md)), 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 [FileCsvDocument.Set(int, int, string)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/set.md) overloads (addressed by column and row), then persist it with [FileCsvDocument.Save(string)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/save.md). Every row has the same number of columns; addressing a column outside that count throws.

## Constructors

- [FileCsvDocument](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/ctor.md): (2 overloads) 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.

## Properties

- [ColumnCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columncount.md): The number of columns in the document. Every row has exactly this many fields.
- [HasHeader](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/hasheader.md): True if the document has a header row of column names. See [FileCsvDocument.ColumnIndex(string)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columnindex.md).
- [Header](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/header.md): The column names, or null if the document has no header. [FileCsvDocument.RowCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/rowcount.md) counts only the data rows; the header is not one of them.
- [RowCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/rowcount.md): The number of rows in the document.

## Indexers

- [this[]](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/item.md): Gets the value of a cell, addressed by column and row. Use [FileCsvDocument.TryGetString(int, int, string)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetstring.md) for access that does not throw when the cell does not exist.

## Methods

- [Clear](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/clear.md): Removes all rows from the document.
- [ColumnIndex](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columnindex.md): 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.
- [GetEnumerator](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/getenumerator.md): Returns an enumerator that iterates over the committed rows of the document.
- [GetRow](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/getrow.md): Returns the fields of a row.
- [Read](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/read.md): (4 overloads, static) Reads a CSV file from disk.
- [Save](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/save.md): (3 overloads) Writes the document to a file on disk using the specified encoding.
- [Set](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/set.md): (14 overloads) Sets the value of a cell to a boolean, written as "1" (true) or "0" (false).
- [SetRow](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/setrow.md): (2 overloads) 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 [FileCsvDocument.GetRow(int)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/getrow.md). The number of fields must equal [FileCsvDocument.ColumnCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columncount.md). A null field is stored as an empty field.
- [IEnumerable.GetEnumerator](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/system-collections-ienumerable-getenumerator.md)
- [ToString](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/tostring.md): Returns the full CSV content of the document as a string.
- [TryGetBool](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetbool.md): (2 overloads) Retrieves the value of a cell as a boolean. Recognizes "true"/"false", "yes"/"no", and "1"/"0" (case-insensitive, surrounding whitespace ignored).
- [TryGetColor](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetcolor.md): (2 overloads) Retrieves the value of a cell as a color from its 32-bit ARGB integer ([Color.FromArgb(int)](https://learn.microsoft.com/dotnet/api/system.drawing.color.fromargb)), as written by [FileCsvDocument.Set(int, int, Color)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/set.md).
- [TryGetDateTime](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetdatetime.md): (2 overloads) Retrieves the value of a cell as a date and time, parsed with the invariant culture and [DateTimeStyles.RoundtripKind](https://learn.microsoft.com/dotnet/api/system.globalization.datetimestyles.roundtripkind) (so ISO 8601 values, including those written by [FileCsvDocument.Set(int, int, DateTime)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/set.md), round-trip).
- [TryGetDouble](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetdouble.md): (2 overloads) Retrieves the value of a cell as a double-precision number. The cell is evaluated with [RhinoMath.TryParseNumber(string, double)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.rhinomath/tryparsenumber.md), so command-line math expressions (for example "1/2") are supported.
- [TryGetGuid](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetguid.md): (2 overloads) Retrieves the value of a cell as a globally unique identifier. Accepts any of the formats understood by [Guid.TryParse(string, Guid)](https://learn.microsoft.com/dotnet/api/system.guid.tryparse) (with or without hyphens or braces).
- [TryGetInt](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetint.md): (2 overloads) Retrieves the value of a cell as a 32-bit integer, parsed using the invariant culture.
- [TryGetLong](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetlong.md): (2 overloads) Retrieves the value of a cell as a 64-bit integer, parsed using the invariant culture.
- [TryGetPoint](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetpoint.md): Retrieves a row as a 3-D point. This succeeds only when [FileCsvDocument.ColumnCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/columncount.md) is 3: the row's three fields are joined and passed to [Point3d.TryParse(string, Point3d)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.geometry.point3d/tryparse.md).
- [TryGetString](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.filecsvdocument/trygetstring.md): (2 overloads) Retrieves the value of a cell as a string.
