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!
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

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
53,324
Office Version
  1. 365
Platform
  1. 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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,427
Messages
5,601,605
Members
414,462
Latest member
StageRiis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top