To convert the character encoding of a CSV file to UTF-8, follow these steps:
- Identify the Current Encoding:
- Open the CSV file in an editor like Notepad++ or Excel.
-
Check the encoding settings; Notepad++ can detect it under “Encoding.”
-
Choose a Conversion Tool:
- Notepad++: Use the “Encoding” menu to convert directly.
- Excel: Open the CSV, save as UTF-8 under “File > Save As.”
-
Command Line Tools: Use iconv or Python scripts for automated processes.
-
Convert Encoding Using Notepad++:
- Open your file in Notepad++.
- Navigate to “Encoding” and select “Detect…” if unsure, then choose the detected encoding.
-
Select “UTF-8” from the Encoding menu and save the file.
-
Use Excel for Conversion:
- Open the CSV file in Excel.
- Go to “File > Save As,” choose “CSV UTF-8 (*.csv)” as the format.
-
Save your changes.
-
Command Line with iconv:
-
Open a terminal and run:
iconv –f original_encoding –t utf–8 file.csv > new_file.csv
Replace original_encoding with the current encoding (e.g., ISO-8859-1). -
Verify the Conversion:
- Ensure no data loss or corruption by opening the converted file in a text editor or application.
By following these steps, you can reliably convert your CSV file to UTF-8 encoding.