Creating CSV files for use with Excel

CSV files

Working on a recent project, I was using PowerShell to manipulate a list of MS Word documents that I had to process. Reading other articles on the Internet, I realised how useful it would be if I could create a list of files of interest in a CSV file and import this into Microsoft Excel in the usual way.

Although the example given is looking at PDF files, the principle is the same.


Get-ChildItem -Path $inputPath -Filter *.pdf -Recurse |
    Select-Object DirectoryName, Name, LastWriteTime |
    Export-Csv -Path $outputCsv -Encoding ascii -NoTypeInformation;

The Select-Object Cmdlet is used to select the file attributes I want in my CSV file.


See also

Use PowerShell to Create CSV File to Open in Excel

Using the Select-Object Cmdlet

Select-Object Cmdlet

Keywords: powershell csv import

This entry was posted in powershell and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s