# ConvertFrom-OfficeCsv

Converts CSV text into PSCustomObjects, dictionaries, a DataTable, a data reader or a CsvDocument.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`System.String[]`

**Outputs**

`System.Management.Automation.PSObject` `System.Collections.Hashtable` `System.Data.DataTable` `System.Data.IDataReader` `OfficeIMO.CSV.CsvDocument`

**Source**

[ConvertFromOfficeCsvCommand.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Csv/ConvertFromOfficeCsvCommand.cs#L33) 

Converts CSV text into PSCustomObjects, dictionaries, a DataTable, a data reader or a CsvDocument.

## Syntax

```
ConvertFrom-OfficeCsv
[-AllowEmptyLines]
[-As <Object|Hashtable|DataTable|DataReader|Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-Delimiter <String>]
[-DuplicateHeaderBehavior <Preserve|Rename|Throw>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InputObject] <String[]>
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw|SkipRow>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient|Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]
```

[#](#member-f027b9a4db4fea4f522cdf7e)

Parameter set: `InputObject`

```
ConvertFrom-OfficeCsv
[-AllowEmptyLines]
[-As <Object|Hashtable|DataTable|DataReader|Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DelimiterCandidates <Char[]>]
-DetectDelimiter
[-DuplicateHeaderBehavior <Preserve|Rename|Throw>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InputObject] <String[]>
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw|SkipRow>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient|Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]
```

[#](#member-d3c2484f418909d50dd79416)

Parameter set: `InputObjectDetect`

```
ConvertFrom-OfficeCsv
[-AllowEmptyLines]
[-As <Object|Hashtable|DataTable|DataReader|Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DuplicateHeaderBehavior <Preserve|Rename|Throw>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InputObject] <String[]>
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw|SkipRow>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient|Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
-UseCulture
[<CommonParameters>]
```

[#](#member-49f9ed47418b62eb7544e365)

Parameter set: `InputObjectCulture`

## Description

The reverse of ConvertTo-OfficeCsv and the text form of Import-OfficeCsv: piped strings are read as lines of one CSV text, as ConvertFrom-Csv reads them, and parsed with Import-OfficeCsv's options and output shapes. Use Import-OfficeCsv when the source is a file.

## Examples

### Read CSV text as objects.

```powershell
"Name,Total`nAlpha,10`nBeta,7" | ConvertFrom-OfficeCsv
```

Emits one PSCustomObject per row, with property names from the header.

### Round-trip objects through CSV text.

```powershell
$rows = Get-Process | Select-Object -First 5 Name, Id | ConvertTo-OfficeCsv | ConvertFrom-OfficeCsv
```

Reads the text ConvertTo-OfficeCsv writes back into objects.

### Read semicolon-separated lines as a typed DataTable.

```powershell
Get-Content ./export.txt | ConvertFrom-OfficeCsv -Delimiter ';' -As DataTable -InferSchema
```

Joins the lines Get-Content emits and infers column types from the values.

## Parameters

**-AllowEmptyLines SwitchParameter optional**

Allow empty lines in the input.

**-As OfficeCsvOutput optional**

Output shape: Object, Hashtable, DataTable, DataReader or Document.

Possible values: `Object`, `Hashtable`, `DataTable`, `DataReader`, `Document`

**-CollectParseErrors SwitchParameter optional**

Collect parse errors and write them as non-terminating errors after the rows.

**-ColumnCountMismatchPolicy CsvColumnCountMismatchPolicy optional**

Controls how rows with fewer or more fields than the header are handled.

Possible values: `Strict`, `PadMissingFieldsAndIgnoreExtraFields`

**-ColumnType IDictionary optional**

Explicit column types used when emitting DataTable or IDataReader output.

**-CommentCharacter Char optional**

Character that identifies comment rows.

**-Culture CultureInfo optional**

Culture used for type conversions, and for the delimiter with UseCulture.

**-DateTimeFormats String[] optional**

Additional date/time formats used by typed conversions and validation.

**-Delimiter String optionalsets: InputObject**

Field delimiter, including multi-character delimiters.

**-DuplicateHeaderBehavior CsvDuplicateHeaderBehavior optional**

Controls how duplicate header names are handled.

Possible values: `Preserve`, `Rename`, `Throw`

**-EscapeCharacter Char optional**

Character that escapes the quote character, or itself, inside quoted fields, such as a backslash. Leave unset to read a doubled quote character as one.

**-Header String[] optional**

Explicit header names to use; when provided, the first CSV record is treated as data.

**-InferSchema SwitchParameter optional**

Infer typed columns when -As DataTable or -As DataReader is used.

**-InputObject String[] requiredposition: 0pipeline: True (ByValue)**

CSV text, as one string or as lines; piped strings are joined with line breaks.

**-InternStrings SwitchParameter optional**

Reuse repeated string values through a per-read cache.

**-MaxFieldLength Int32 optional**

Maximum length allowed for any parsed field.

**-MaxParseErrors Int32 optional**

Maximum number of collected parse errors before parsing fails.

**-MaxQuotedFieldLength Int32 optional**

Maximum length allowed for fields parsed from quoted records.

**-NoHeader SwitchParameter optional**

Treat the first record as data and generate default column names.

**-NormalizeQuotes SwitchParameter optional**

Normalize curly quote characters to straight quotes.

**-NoSkipCommentRowsBeforeHeader SwitchParameter optional**

Keep comment rows while discovering the header.

**-NoW3CFieldsHeader SwitchParameter optional**

Disable W3C Extended Log File Format #Fields: headers.

**-NullValue String optional**

Token that is materialized as null.

**-ParseErrorAction CsvParseErrorAction optional**

How parse errors are handled.

Possible values: `Throw`, `SkipRow`

**-QuoteCharacter Char optional**

Character that encloses quoted fields. Defaults to the double quote.

**-QuoteParsingMode CsvQuoteParsingMode optional**

Controls whether malformed quoted fields are parsed leniently or rejected.

Possible values: `Lenient`, `Strict`

**-SchemaSampleRows Int32 optional**

Maximum row count inspected when schema inference is enabled.

**-SkipCommentRows SwitchParameter optional**

Skip comment rows throughout the text.

**-SkipRows Int32 optional**

Number of parsed CSV records to skip before header discovery or data output.

**-StaticColumns IDictionary optional**

Static columns appended to every row.

**-TrimWhitespace SwitchParameter optional**

Trim whitespace around unquoted fields.

**-DelimiterCandidates Char[] optionalsets: InputObjectDetect**

Delimiter candidates to consider when detecting the delimiter.

**-DetectDelimiter SwitchParameter requiredsets: InputObjectDetect**

Detect the delimiter from the first meaningful records.

**-UseCulture SwitchParameter requiredsets: InputObjectCulture**

Use the list separator from the selected or current culture as the delimiter.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:E1C881594239783E55FE9AE7675DF0BA913EEC1B8B06BA3AE3B0FD44F833F963 -->
