0
Before you tell me to search more and to look at other people's questions and their answers read my precise question.
Most other topics here deal with how to make UTF-8 the default option within the text import wizard. However, I would like to avoid having to use the text import wizard at all.
I have CSV files that I want to open by double clicking. Excel opens them automatically, but even if I did the regedit trick of using 65001 (UTF-8) as the default encoding, the files are still not correctly displayed.
Is there some way to force this encoding in the opening of a file instead of having to import it?
Thanks in advance
(using Excel 2016 in US English and my Windows 7 regional configuration is set to Spanish (United States), I don't know if that is important, but it actually was for dealing with default commas as separators)
EDIT for clarification: accents and characters from other languages still appear as weird codes when opening a CSV file after doing the regedit trick of forcing utf-8 for the import. I am not importing though (the trick works as expected there); I am opening the file directly.
Thanks @nixda This looks like an amazing. I can't make it work though. I tried the sendto script, and even though I followed the instructions, nothing happens. After I rightclick -> sendto -> script, nothing happens. What appears to be a cmd window appears very briefly and disappears, but excel does not run.
I also tried the PS2EXE method, but when I run the script the message "THE POWERSHELL VERSION IS UNKNOWN", which, according to the ps2exe.ps1 file (opened in notepad) belongs to
if( $psversion -eq 0 ) { write-host "THE POWERSHELL VERSION IS UNKNOWN!" exit -1 }
– Nicolás Fernández Fioretti – 2017-05-26T10:20:38.463@NicolásFernándezFioretti Could it be that you haven't allowed Windows to execute Powershell script? Default is
– nixda – 2017-05-26T13:04:24.090restricted
. Check it in PoewerShell withGet-ExecutionPolicy
. And if needed start PS as administrator and set it toset-executionpolicy remotesigned
orSet-ExecutionPolicy unrestricted
I am using a corporate computer, so I may have special restrictions i am not aware of. I can run powershell as administrator, and
get-executionpolicy
returnsunrestricted
, butset-executionpolicy
says I do not have access to modifiyng the registry. I am suspecting that even if I am right-clicking powershell and selecting 'run as administrator' I am running it normally, since there is no administrator indication on the title bar of the powershell window. – Nicolás Fernández Fioretti – 2017-05-26T15:58:31.617@NicolásFernándezFioretti To see where the problem is ,please try the following: Open Powershell ISE (that's the build in editor) and paste the above script into it. Now add as first line this
$args = "C:\my\test.csv"
. Change the path to an existing test CSV on your drive. Does it open Excel and import the CSV? – nixda – 2017-05-28T09:29:24.500It works! pasting the script in powershell and using the path to the file opened it with the correct treatment for utf8. I also tried again the "send to" method, and it worked well. I seem to have trouble crating an .exe with PS2EXE. Should I ask for help elsewhere? – Nicolás Fernández Fioretti – 2017-05-30T09:28:11.653
@NicolásFernándezFioretti It could be that all executables created via PS2EXE can only be run on machines where the .NET version is not higher than 4.0. So the error is maybe not on your side – nixda – 2017-05-30T11:58:22.673
Well. Too bad. Just out of curiosity: why is it so hard to do this with the best and most popular spreadsheet editor in the world? LibreOffice handles CSV with UTF8 perfectly fine and has no trouble with list-separating semicolons or date formatting. Is this not a commonly requested feature? – Nicolás Fernández Fioretti – 2017-05-30T19:57:13.897
@NicolásFernándezFioretti Yes, it is a commly requested feature - for many years now. Have a look at this old, but popular question
– nixda – 2017-05-30T21:41:25.303