Cmdlet
Import-OfficeCsv
Imports CSV rows as PSCustomObjects, dictionaries, or a DataTable.
Syntax
Import-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-Delimiter <String>]
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-Path] <String[]>
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
PathImport-OfficeCsv
[-As <Object| Hashtable| DataTable| DataReader| Document>]
-Document <CsvDocument>
[<CommonParameters>]#Parameter set:
DocumentImport-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-Path] <String[]>
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
-UseCulture
[<CommonParameters>]#Parameter set:
PathCultureImport-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DelimiterCandidates <Char[]>]
-DetectDelimiter
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-Path] <String[]>
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
PathDetectImport-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-Delimiter <String>]
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
-LiteralPath <String[]>
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
LiteralPathImport-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
-LiteralPath <String[]>
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
-UseCulture
[<CommonParameters>]#Parameter set:
LiteralPathCultureImport-OfficeCsv
[-AllowEmptyLines]
[-As <Object| Hashtable| DataTable| DataReader| Document>]
[-CollectParseErrors]
[-ColumnCountMismatchPolicy <Strict| PadMissingFieldsAndIgnoreExtraFields>]
[-ColumnType <IDictionary>]
[-CommentCharacter <Char>]
[-CompressionType <Auto| GZip| Deflate| Brotli| ZLib>]
[-Culture <CultureInfo>]
[-DateTimeFormats <String[]>]
[-DelimiterCandidates <Char[]>]
-DetectDelimiter
[-DuplicateHeaderBehavior <Preserve| Rename| Throw>]
[-Encoding <Encoding>]
[-EscapeCharacter <Char>]
[-Header <String[]>]
[-InferSchema]
[-InternStrings]
-LiteralPath <String[]>
[-MaxDecompressedBytes <Int64>]
[-MaxFieldLength <Int32>]
[-MaxInputBytes <Int64>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
LiteralPathDetectImport-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]
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
-Text <String>
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
TextImport-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]
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
-Text <String>
[-TrimWhitespace]
-UseCulture
[<CommonParameters>]#Parameter set:
TextCultureImport-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]
[-InternStrings]
[-MaxFieldLength <Int32>]
[-MaxParseErrors <Int32>]
[-MaxQuotedFieldLength <Int32>]
[-Mode <Stream| InMemory>]
[-NoHeader]
[-NormalizeQuotes]
[-NoSkipCommentRowsBeforeHeader]
[-NoW3CFieldsHeader]
[-NullValue <String>]
[-ParseErrorAction <Throw| SkipRow>]
[-ProgressInterval <Int32>]
[-QuoteCharacter <Char>]
[-QuoteParsingMode <Lenient| Strict>]
[-SchemaSampleRows <Int32>]
[-SkipCommentRows]
[-SkipRows <Int32>]
[-StaticColumns <IDictionary>]
-Text <String>
[-TrimWhitespace]
[<CommonParameters>]#Parameter set:
TextDetectDescription
Uses the CSV header to map fields to property names.
Examples
Read rows as PSCustomObjects.
Import-OfficeCsv -Path .\data.csv | Format-TableImports each row as a PSCustomObject.
Read rows as dictionaries.
Import-OfficeCsv -Path .\data.csv -As Hashtable | ForEach-Object { $_['Name'] }Uses hashtables for dynamic schemas or key-based access.
Read rows as a DataTable.
Import-OfficeCsv -Path .\data.csv -As DataTableEmits one DataTable per input file for database and table-oriented workflows.
Parameters
- -AllowEmptyLines SwitchParameter
- Allow empty lines in the input.
- -As OfficeCsvOutput
- Output shape: Object, Hashtable, DataTable, DataReader or Document.
- Possible values:
Object,Hashtable,DataTable,DataReader,Document - -CollectParseErrors SwitchParameter
- Collect parse errors and write them as non-terminating errors after each file.
- -ColumnCountMismatchPolicy CsvColumnCountMismatchPolicy
- Controls how rows with fewer or more fields than the header are handled.
- Possible values:
Strict,PadMissingFieldsAndIgnoreExtraFields - -ColumnType IDictionary
- Explicit column types used when emitting DataTable or IDataReader output.
- -CommentCharacter Char
- Character that identifies comment rows.
- -CompressionType CsvCompressionType
- Compression used when reading files. Auto infers from the file extension.
- Possible values:
Auto,GZip,Deflate,Brotli,ZLib - -Culture CultureInfo
- Culture used for type conversions.
- -DateTimeFormats String[]
- Additional date/time formats used by typed conversions and validation.
- -Delimiter String
- Field delimiter, including multi-character delimiters.
- -DuplicateHeaderBehavior CsvDuplicateHeaderBehavior
- Controls how duplicate header names are handled.
- Possible values:
Preserve,Rename,Throw - -Encoding Encoding
- Encoding used when reading the file.
- -EscapeCharacter Char
- 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[]
- Explicit header names to use; when provided, the first CSV record is treated as data.
- -InferSchema SwitchParameter
- Infer typed columns when -As DataTable or -As DataReader is used.
- -InternStrings SwitchParameter
- Reuse repeated string values through a per-read cache.
- -MaxDecompressedBytes Int64
- Maximum decompressed bytes to read from compressed CSV files.
- -MaxFieldLength Int32
- Maximum length allowed for any parsed field.
- -MaxInputBytes Int64
- Maximum input bytes to read. Streamed imports read files of any size unless this is set; imports that load the whole file into memory default to 256 MiB.
- -MaxParseErrors Int32
- Maximum number of collected parse errors before parsing fails.
- -MaxQuotedFieldLength Int32
- Maximum length allowed for fields parsed from quoted records.
- -Mode CsvReadMode
- Load mode controlling materialization.
- Possible values:
Stream,InMemory - -NoHeader SwitchParameter
- Treat the first record as data and generate default column names.
- -NormalizeQuotes SwitchParameter
- Normalize curly quote characters to straight quotes.
- -NoSkipCommentRowsBeforeHeader SwitchParameter
- Keep comment rows while discovering the header.
- -NoW3CFieldsHeader SwitchParameter
- Disable W3C Extended Log File Format #Fields: headers.
- -NullValue String
- Token that is materialized as null when importing rows.
- -ParseErrorAction CsvParseErrorAction
- How parse errors are handled.
- Possible values:
Throw,SkipRow - -Path String[]
- Path to one or more CSV files. Wildcards are supported.
- -ProgressInterval Int32
- Report progress every N parsed records.
- -QuoteCharacter Char
- Character that encloses quoted fields. Defaults to the double quote.
- -QuoteParsingMode CsvQuoteParsingMode
- Controls whether malformed quoted fields are parsed leniently or rejected.
- Possible values:
Lenient,Strict - -SchemaSampleRows Int32
- Maximum row count inspected when schema inference is enabled.
- -SkipCommentRows SwitchParameter
- Skip comment rows throughout the file.
- -SkipRows Int32
- Number of parsed CSV records to skip before header discovery or data output.
- -StaticColumns IDictionary
- Static columns appended to every imported row.
- -TrimWhitespace SwitchParameter
- Trim whitespace around unquoted fields.
- -Document CsvDocument
- CSV document to read when already loaded.
- -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.
- -LiteralPath String[]
- Literal path to one or more CSV files.
- -Text String
- CSV text to parse without creating a temporary file.
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.