Converting Excel CSV to UTF8

by | October 3,2013

Table of Contents

When you export Microsoft Excel spreadsheets to CSV files, Excel by default saves CSV files in ANSI encoding. That’s bad because special characters will break once you import the data into PowerShell using Import-Csv.

Ensuring UTF-8 Encoding for CSV Files

To make sure special characters won’t get lost, you can make sure the CSV file uses UTF8 encoding before you import the data:

$Path = 'c:\temp\somedata.csv'

(Get-Content -Path $Path) | Set-Content -Path $Path -Encoding UTF8 

ReTweet this Tip!