CmdID

CmdID / PowerShell / Cmdlets / ConvertFrom

ConvertFrom-Csv

Converts object properties in character-separated value (CSV) format into CSV versions of the original objects. PowerShell reference

From the PowerShell reference 4 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Converts object properties in character-separated value (CSV) format into CSV versions of the original objects. The ConvertFrom-Csv cmdlet converts character-separated value (CSV) data to PSObject type objects for each line of CSV data. The new objects are written to the pipeline in the order they are read from the CSV data. The values in column header row of the CSV become the names of the properties added to each new PSObject. The objects that ConvertFrom-Csv creates are PSObject type object for each row in the CSV file. The property values of the CSV objects are string versions of the property values of the original objects. The CSV versions of the objects don't have any methods. You can also use the Export-Csv and Import-Csv cmdlets to convert objects to CSV strings in a file and back. These cmdlets are the same as the ConvertTo-Csv and ConvertFrom-Csv cmdlets, except that they save the CSV strings in a file. The PSObject type maintains the order of the properties in column header order. This means that you get the same column order when you convert the objects back into CSV format.

ConvertFrom-Csv [-InputObject] <psobject[]> [[-Delimiter] <char>] [-Header <string[]>] [<CommonParameters>]
ConvertFrom-Csv [-InputObject] <psobject[]> -UseCulture [-Header <string[]>] [<CommonParameters>]

Convert processes on the local computer to CSV format

$P = Get-Process | ConvertTo-Csv $P | ConvertFrom-CsvIdentify

Convert a data object to CSV format and then to CSV object format

$Date = Get-Date | ConvertTo-Csv -Delimiter ';' ConvertFrom-Csv -InputObject $Date -Delimiter ';'Identify

Use the header parameter to change the names of properties

$J = Start-Job -ScriptBlock { Get-Process } | ConvertTo-Csv -NoTypeInformation $Header = 'State', 'MoreData', 'StatusMessage', 'Location', 'Command', 'StateInfo', 'Finished', 'InstanceId', 'Id', 'Name', 'ChildJobs', 'BeginTime', 'EndTime', 'JobType', 'Output', 'Error', 'Progress', 'Verbose', 'Debug', 'Warning', 'Information' # Delete the default header from $J $J = $J[1..($J.Count - 1)] $J | ConvertFrom-Csv -Header $HeaderIdentify

Convert CSV strings of service objects

(Get-Culture).TextInfo.ListSeparator $Services = (Get-Service | ConvertTo-Csv) ConvertFrom-Csv -InputObject $Services -UseCultureIdentify

Convert CSV data in W3C Extended Log Format

$logData = @" #Version: 1.0 #Fields: time,cs-method,cs-uri 00:34:23,GET,/foo/bar.html 12:21:16,GET,/foo/bar.html 12:45:52,GET,/foo/bar.html 12:57:34,GET,/foo/bar.html "@ ConvertFrom-Csv $logDataIdentify

Its page in the reference: ConvertFrom-Csv.

Parameters

4 in the PowerShell reference
-DelimiterSpecifies the delimiter that separates the property values in the CSV data. The default is a comma (,). Enter a character, such as a colon (:). To specify a semicolon (;), enclose it in single quotation marks. To specify escaped special characters such as tab ( t ), enclose it in double quotation marks. If the specified character doesn't match the actual delimiter in the CSV data, ConvertFrom-Csv can't parse each column into distinct properties. In this case, it outputs one PSCustomObject per row, each containing a single property whose name is the full header and whose value is the row text.
-HeaderSpecifies an alternate column header row for the imported string. The column header determines the property names of the objects created by ConvertFrom-Csv. Enter column headers as a character-separated list. don't enclose the header string in quotation marks. Enclose each column header in single quotation marks. If you enter fewer column headers than there are data columns, the remaining data columns are discarded. If you enter more column headers than there are data columns, the additional column headers are created with empty data columns. When using the Header parameter, omit the column header string from the CSV strings. Otherwise, this cmdlet creates an extra object from the items in the header row.
-InputObjectSpecifies the CSV strings to be converted to objects. Enter a variable that contains the CSV strings or type a command or expression that gets the CSV strings. You can also pipe the CSV strings to ConvertFrom-Csv.
-UseCultureUses the list separator for the current culture as the item delimiter. To find the list separator for a culture, use the following command: (Get-Culture).TextInfo.ListSeparator.