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