Issues with character encoding?

juk77

New Member
Joined
Sep 5, 2019
Messages
4
What I have:
A bunch of CSV files with data. Say 300k rows each one.


CSV files: if opened directly, they're in the wrong encoding and characters don't show up as they should. There's no option to select which
encoding to use or which should be the default for all files?


What also doesn't work:
Converting to xls/xlsx using an excel vba batch convert:
https://www.extendoffice.com/documents/excel/4615-excel-batch-convert-csv-to-xls-xlsx.html
Obviously this code just opens the file directly then saves under the new extension, doesn't solve the encoding thing. (also errors on the xlsx file on opening)


What does work:
Importing from file - CSV
Defaults to Western European but can be manually changed to 65001: Unicode (UTF-8) which works and shows special characters.


What I'm trying to end up with:
1. A batch script like the above one to convert files but would work off an import (and setting the encoding to UTF) as opposed to a direct open, that'll convert all csv files in a folder to xls with the right encoding.
Is this possible somehow with VBA?

2. A script that imports each csv file to the current workbook, each in a different worksheet. or similar.

Number 1 is the priority but any examples I can find uses the standard open vba code, meaning it'd not have the right encoding.

Alternatively if anyone knows how to force Excel to open a csv file with Unicode encoding, that'd also help!

Thanks for any input!
 

juk77

New Member
Joined
Sep 5, 2019
Messages
4
Can't figure out how to edit posts, but what also works: those csv to excel online converters, but they're a) obviously not the best option and b) usually are slow and have file size limits. so trying to move away from them!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,509
Office Version
365
Platform
Windows
If you record a macro of you importing the csv & changing the settings as required, it will give you the base code that can then be built upon to import all the files in a folder.
 

Forum statistics

Threads
1,085,009
Messages
5,381,186
Members
401,718
Latest member
Ereese20

Some videos you may like

This Week's Hot Topics

Top