Friday, June 13, 2008

Enhanced CSV file handling in CTP2


In PowerShell v1 you could import comma separated CSV files only. That's not a problem anymore in CTP2. The Import/Export CSV cmdlets got enhanced and now they support a new -delimiter parameter:


PS > get-help import-csv -Parameter delimiter

-Delimiter [<char>]
    Specifies the delimiter that separates the property values in the file that is being imported. The default is a com
    ma (,). Enter a character, such as a semicolon (;).

    Required?                    false
    Position?                    2
    Default value                ,
    Accept pipeline input?       false
    Accept wildcard characters?  false


Note that the delimiter is limited to a single character.

# Export processes to a space separated csv file
PS > get-process | export-csv -delimiter " " -path processes.csv
# Convert csv files: comma separated to tab separated

PS > import-csv test.csv | export-csv -del "`t" -p test1.csv

No comments: