Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

ConvertFrom-OfficeCsv

Module PSWriteOffice
Inputs
System.String

Converts CSV text to PSCustomObjects or dictionaries.

Syntax

ConvertFrom-OfficeCsv [-AllowEmptyLines] [-AsHashtable] [-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>] [-CommentCharacter <Char>] [-Culture <CultureInfo>] [-DateTimeFormats <String[]>] [-Delimiter <Char>] [-DelimiterText <String>] [-DuplicateHeaderBehavior <Preserve|Rename|Throw>] [-Header <String[]>] [-Mode <Stream|InMemory>] [-NoHeader] [-NullValue <String>] [-QuoteParsingMode <Lenient|Strict>] [-RecognizeW3CFieldsHeader <Boolean>] [-SkipCommentRows] [-SkipCommentRowsBeforeHeader <Boolean>] [-SkipRows <Int32>] [-StaticColumns <IDictionary>] [-Text] <String> [-TrimWhitespace <Boolean>] [<CommonParameters>]
#
Parameter set: TextDelimiter
ConvertFrom-OfficeCsv [-AllowEmptyLines] [-AsHashtable] [-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>] [-CommentCharacter <Char>] [-Culture <CultureInfo>] [-DateTimeFormats <String[]>] [-DuplicateHeaderBehavior <Preserve|Rename|Throw>] [-Header <String[]>] [-Mode <Stream|InMemory>] [-NoHeader] [-NullValue <String>] [-QuoteParsingMode <Lenient|Strict>] [-RecognizeW3CFieldsHeader <Boolean>] [-SkipCommentRows] [-SkipCommentRowsBeforeHeader <Boolean>] [-SkipRows <Int32>] [-StaticColumns <IDictionary>] [-Text] <String> [-TrimWhitespace <Boolean>] -UseCulture [<CommonParameters>]
#
Parameter set: TextCulture
ConvertFrom-OfficeCsv [-AllowEmptyLines] [-AsHashtable] [-ColumnCountMismatchPolicy <Strict|PadMissingFieldsAndIgnoreExtraFields>] [-CommentCharacter <Char>] [-Culture <CultureInfo>] [-DateTimeFormats <String[]>] [-DelimiterCandidates <Char[]>] -DetectDelimiter [-DuplicateHeaderBehavior <Preserve|Rename|Throw>] [-Header <String[]>] [-Mode <Stream|InMemory>] [-NoHeader] [-NullValue <String>] [-QuoteParsingMode <Lenient|Strict>] [-RecognizeW3CFieldsHeader <Boolean>] [-SkipCommentRows] [-SkipCommentRowsBeforeHeader <Boolean>] [-SkipRows <Int32>] [-StaticColumns <IDictionary>] [-Text] <String> [-TrimWhitespace <Boolean>] [<CommonParameters>]
#
Parameter set: TextDetect

Description

Reads CSV text from -Text or the pipeline and maps rows by header.

Examples

Authored help example

Convert CSV text into rows.

$rows = ConvertFrom-OfficeCsv -Text "Name,Value`nAlpha,1"

Parses CSV text and emits row objects without writing a temporary file.

Convert piped CSV lines.

"Name,Value", "Alpha,1" | ConvertFrom-OfficeCsv

Treats piped lines as one CSV stream.

Parameters

-AllowEmptyLines SwitchParameter optional
Allow empty lines in the input.
-AsHashtable SwitchParameter optional
Emit dictionaries instead of PSCustomObjects.
-ColumnCountMismatchPolicy CsvColumnCountMismatchPolicy optional
Controls how rows with fewer or more fields than the header are handled.
Possible values: Strict, PadMissingFieldsAndIgnoreExtraFields
-CommentCharacter Char optional
Character that identifies comment rows.
-Culture CultureInfo optional
Culture used for type conversions.
-DateTimeFormats String[] optional
Additional date/time formats used by typed conversions and validation.
-Delimiter Char optionalsets: TextDelimiter
Field delimiter character.
-DelimiterText String optionalsets: TextDelimiter
Field delimiter text for multi-character delimiters such as || or ::.
-DuplicateHeaderBehavior CsvDuplicateHeaderBehavior optional
Controls how duplicate header names are handled.
Possible values: Preserve, Rename, Throw
-Header String[] optional
Explicit header names to use; when provided, the first CSV record is treated as data.
-Mode CsvReadMode optional
Load mode controlling materialization.
Possible values: Stream, InMemory
-NoHeader SwitchParameter optional
Treat the first record as data and generate default column names.
-NullValue String optional
Token that is materialized as null when converting rows.
-QuoteParsingMode CsvQuoteParsingMode optional
Controls whether malformed quoted fields are parsed leniently or rejected.
Possible values: Lenient, Strict
-RecognizeW3CFieldsHeader Boolean optional
Recognize W3C Extended Log File Format #Fields: rows as headers.
-SkipCommentRows SwitchParameter optional
Skip comment rows throughout the input.
-SkipCommentRowsBeforeHeader Boolean optional
Skip comment rows starting with # while discovering the header.
-SkipRows Int32 optional
Number of parsed CSV records to skip before header discovery or data output.
-StaticColumns IDictionary optional
Static columns appended to every converted row.
-Text String requiredposition: 0pipeline: True (ByValue)
CSV text to parse.
-TrimWhitespace Boolean optional
Trim whitespace around unquoted fields.
-UseCulture SwitchParameter requiredsets: TextCulture
Use the list separator from the selected or current culture as the delimiter.
-DelimiterCandidates Char[] optionalsets: TextDetect
Delimiter candidates to consider when detecting the delimiter.
-DetectDelimiter SwitchParameter requiredsets: TextDetect
Detect the delimiter from the first meaningful records.

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.