Page 1 of 1
Convert .xls and .csv to tab-delimited .txt
Posted: 23 Apr 2009 02:19
by sixty_watt_shaman
Hi,
I have a question. Is it possible to convert a .xls-file and a .csv-file into a tab-delimited .txt-file with a batch-file. If so, how can this be done?
Thanks in advance.
Bram.
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 17 Jun 2014 08:25
by Samir
I hate to bump an older thread, but is there an answer to this? I'm wondering the exact same thing.
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 17 Jun 2014 10:10
by Squashman
Not with batch.
Working with excel files requires Excel to be installed. Vbscript and Powershell are the only scripting languages that I know of that can use excel as an object to do this.
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 17 Jun 2014 17:53
by ShadowThief
You can't edit .xls files, but .csv files are just text files where values are separated by commas, so you can use something like findrepl.bat to just replace all of the commas with tabs.
On a related note, you can edit .xlsx files since they're just an archive of .xml files, but the whole thing is so ludicrously complicated and interconnected that it's really not a good idea to do so.
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 17 Jun 2014 20:28
by dbenham
ShadowThief wrote:... but .csv files are just text files where values are separated by commas, so you can use something like findrepl.bat to just replace all of the commas with tabs.
Potentially it is not that simple because CSV allows both comma and newlines literals within values if they are quoted. And quote literals within a quoted value are escaped as two quotes.
Dave Benham
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 17 Jun 2014 22:24
by ShadowThief
dbenham wrote:ShadowThief wrote:... but .csv files are just text files where values are separated by commas, so you can use something like findrepl.bat to just replace all of the commas with tabs.
Potentially it is not that simple because CSV allows both comma and newlines literals within values if they are quoted. And quote literals within a quoted value are escaped as two quotes.
Dave Benham
You could first delimit by double quotes and then only convert the commas in the odd-numbered tokens
Re: Convert .xls and .csv to tab-delimited .txt
Posted: 24 Jun 2014 22:02
by carlsomo
Hybrid batch/jscript:
viewtopic.php?f=3&t=4628&p=33475#p33475Last post
XLS2CSV "D:\XLpath\my file.xlsx" "D:\CSVfiles\my file.csv" /S=/t
Converts xlsx to tab delimited txt file. I don't think there is a pure batch solution.