Skip to content

Import-Csv Should apply PSTypeNames uppon import when Type Information is present in the CSV #5134

Closed

Description

The seemingly only useful way to use the Type Information currently added by default during Export-Csv would be to reapply the PSTypeNames to the PSCustomObjects. Currently, These Type names are currently prepended with CSV:. This means that exporting a simple PSObject to CSV and then re-importing would require 2 format definitions or add/set the PSTypeNames for the imported objects.

Steps to reproduce

[PSCustomObject]@{
    PSTypeName = 'My.Custom.Object'
    Column1 = 'values1'
} | Export-Csv C:\temp\csv.csv
$import = Import-Csv C:\temp\csv.csv
$import.PSObject.TypeNames

Expected behavior

My.Custom.Object

Actual behavior

CSV:My.Custom.Object

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0-beta.8
PSEdition                      Core
GitCommitId                    v6.0.0-beta.8
OS                             Microsoft Windows 10.0.15063
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Breaking-Change
    Issue-Enhancement
    on Oct 16, 2017
  2. added
    Review - Committee
    on Nov 7, 2017
  3. SteveL-MSFT commented on Nov 7, 2017

    @SteveL-MSFT
    Member

    You could have My.Custom.Object as TypesNames[0] and CSV:My.Custom.Object as TypesNames[1] although I don't know if anyone actually depends on CSV:typename.

  4. added
    Committee-Reviewed
    and removed
    Review - Committee
    on Nov 8, 2017
  5. SteveL-MSFT commented on Nov 8, 2017

    @SteveL-MSFT
    Member

    @PowerShell/powershell-committee reviewed this and ok with a small breaking change where we insert the desired typename in index 0 and add the CSV:typename as index 1.

  6. added a commit that references this issue on Nov 14, 2017
    c832e16
  7. added a commit that references this issue on Aug 6, 2026
    a85b6c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking-ChangeCommittee-ReviewedIssue-EnhancementWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions