This is with reference to my answer to SO post macro separates .csv by comma, despite separator set to semicolon and subsequent post Saving .txt as .csv cancels all changes made by macro in the file. How to prevent it? by @Drzemlik. What at the start was thought to be simple solution to some already negative voted post, during the process of preparing answer it was found that the problem may be worth a bounty?
In my trial, I find while saving semicolon delimited txt/csv files from excel it may introduce some double quotes in the saved file (depending on position of comma, spaces, double quote and semicolon in a line). May refer links Saving a Excel File into .txt format without quotes and link1 and link2.
However, I am not at all satisfied with my workaround approach of opening the Csv/Txt file with Open statement in I/O mode and renaming it. Still I believe I missed out something and there must be Simple and Direct approach to open and save the file in excel only.
Text file involved should consist of comma, spaces, double quote and semicolons, while semicolon is to be treated as delimiter.
File is to be opened directly in excel using ‘OpenText
or
TextToColumns` or likewise, perform some simple truncate operation on a column (say col 2) and saving the same directly from excel.Task may be performed as simple as possible. Most preferably with use of some parameters/ tweaks of
OpenText
and/orsaveAs
that I missed out. Process should be free of Find replace type of manipulation of file content and of introduced double quotes.Finally most challenging is to open the file with
.csv
extension and directly saving it with.csv
extension will be a Kudos.
I am not reproducing any codes (it all there in the links provided), But providing a sample file text for easy trial.
Ln,1 "AND" Col,1; Ln,1 "AND" Col,2; Ln,1 "AND" Col,3; Ln,1 "AND" Col,4; Ln,1 "AND" Col,5; Ln,1 "AND" Col,6; Ln,1 "AND" Col,7; Ln,1 "AND" Col,8;
Ln,2 "AND" Col,1; Ln,2 "AND" Col,2; Ln,2 "AND" Col,3; Ln,2 "AND" Col,4; Ln,2 "AND" Col,5; Ln,2 "AND" Col,6; Ln,2 "AND" Col,7; Ln,2 "AND" Col,8;
Ln,3 "AND" Col,1; Ln,3 "AND" Col,2; Ln,3 "AND" Col,3; Ln,3 "AND" Col,4; Ln,3 "AND" Col,5; Ln,3 "AND" Col,6; Ln,3 "AND" Col,7; Ln,3 "AND" Col,8;
Ln,4 "AND" Col,1; Ln,4 "AND" Col,2; Ln,4 "AND" Col,3; Ln,4 "AND" Col,4; Ln,4 "AND" Col,5; Ln,4 "AND" Col,6; Ln,4 "AND" Col,7; Ln,4 "AND" Col,8;
Ln,5 "AND" Col,1; Ln,5 "AND" Col,2; Ln,5 "AND" Col,3; Ln,5 "AND" Col,4; Ln,5 "AND" Col,5; Ln,5 "AND" Col,6; Ln,5 "AND" Col,7; Ln,5 "AND" Col,8;
Ln,6 "AND" Col,1; Ln,6 "AND" Col,2; Ln,6 "AND" Col,3; Ln,6 "AND" Col,4; Ln,6 "AND" Col,5; Ln,6 "AND" Col,6; Ln,6 "AND" Col,7; Ln,6 "AND" Col,8;
Ln,7 "AND" Col,1; Ln,7 "AND" Col,2; Ln,7 "AND" Col,3; Ln,7 "AND" Col,4; Ln,7 "AND" Col,5; Ln,7 "AND" Col,6; Ln,7 "AND" Col,7; Ln,7 "AND" Col,8;
Ln,8 "AND" Col,1; Ln,8 "AND" Col,2; Ln,8 "AND" Col,3; Ln,8 "AND" Col,4; Ln,8 "AND" Col,5; Ln,8 "AND" Col,6; Ln,8 "AND" Col,7; Ln,8 "AND" Col,8;
Ln,9 "AND" Col,1; Ln,9 "AND" Col,2; Ln,9 "AND" Col,3; Ln,9 "AND" Col,4; Ln,9 "AND" Col,5; Ln,9 "AND" Col,6; Ln,9 "AND" Col,7; Ln,9 "AND" Col,8;
Ln,10 "AND" Col,1; Ln,10 "AND" Col,2; Ln,10 "AND" Col,3; Ln,10 "AND" Col,4; Ln,10 "AND" Col,5; Ln,10 "AND" Col,6; Ln,10 "AND" Col,7; Ln,10 "AND" Col,8;
Ln,11 "AND" Col,1; Ln,11 "AND" Col,2; Ln,11 "AND" Col,3; Ln,11 "AND" Col,4; Ln,11 "AND" Col,5; Ln,11 "AND" Col,6; Ln,11 "AND" Col,7; Ln,11 "AND" Col,8;
Ln,12 "AND" Col,1; Ln,12 "AND" Col,2; Ln,12 "AND" Col,3; Ln,12 "AND" Col,4; Ln,12 "AND" Col,5; Ln,12 "AND" Col,6; Ln,12 "AND" Col,7; Ln,12 "AND" Col,8;
Ln,13 "AND" Col,1; Ln,13 "AND" Col,2; Ln,13 "AND" Col,3; Ln,13 "AND" Col,4; Ln,13 "AND" Col,5; Ln,13 "AND" Col,6; Ln,13 "AND" Col,7; Ln,13 "AND" Col,8;
Ln,14 "AND" Col,1; Ln,14 "AND" Col,2; Ln,14 "AND" Col,3; Ln,14 "AND" Col,4; Ln,14 "AND" Col,5; Ln,14 "AND" Col,6; Ln,14 "AND" Col,7; Ln,14 "AND" Col,8;
*.csv
file directly in Excel (using standard methods). You have to create customCsvReader
&CsvWriter
class. – Maciej Los