how to convert txt to xls using cmd - excel

I want to convert the result file txt which columns are separated in pipes (|) to an excel file spreedsheet.
I don't want to use Excel app. I need to do it via batch file.
what is the best option? I was thinking in an external app but I don't know which is the best.

I'm not sure about batch, but if you have access to PowerShell, the information here may help:
How to export a CSV to Excel using Powershell

Related

Batch file creation: Convert xls to csv using only batch script

I have done quite a bit of searching before posting this question so let me outline what I am trying to do.
1.) I do not want to use applications I have to download from a website or created custom commands (please no start Xls2Csv.exe here's a link to a website where you can download the program) I do not want to download a program to do this.
2.) I want to keep it in the batch file if possible - I have tried the vbc/vbs/vb files that is not what I am looking for.
3.) I found this an this is close to what I need but if I can stay within a batch file that would be best: Can a Batch File Tell a program to save a file as? (If so how)
Background
I have a bunch of test records stored in excel sheets within folders. Each test record has autoformatted name so the only real difference between any of the filenames is a serial number, otherwise each file name is formatted the exact same way.
I have written a batch file to search and find the files I need but I am stuck on obtaining a tiny bit of information in a .xls file.
What I am trying to do - I have excel files (.xls) and there is a word in a cell on one of many sheets that I would like to copy into a textfile. However I am unable to use findstr for an excel find because the command searches the file as if you opened it in notepad and the data I need is not present.
I am not concerned of data loss as long as I can get this tiny bit of information to a text file.
Otherwise what I have found to be the best solution is to convert an XLS to a CSV. I have manually done it by opening the file and saving as type .csv that worked.
What hasn't worked is:
example1.xls >> example2.csv
ren example1.xls example3.csv - this will save it as a csv file but still opens with the same formating of the xls file in both excel and notepad.
I was hoping that the was a command to recreate the manual process of opening the file and saving as csv.
If there are any other suggested solutions - maybe a command where I can search for a string within an excel file? That would be the simplest option.

Agnostically convert spreadsheet to csv file

I have a script that takes a csv and does something with it.
I'd like this script to be agnostic to the spreadsheet file type (xlsx, xls, ods for instance), and always convert the file to csv for processing. Is there a way to do this without corrupting the data in any way?
You can use a headless version of the open-source software, Libreoffice, to convert the same extensions that Libreoffice can normally do within in the GUI. This solution does require you to install the whole office suite which may be overkill depending on your particular situation.
However, via the command line, you can call Libreoffice to do this conversion:
soffice --headless --convert-to csv <input_file> --outdir </path/to/dir>
This example is under the assumption that you are using a Unix-like machine, however there should be a similar version for Windows as well (e.g. soffice.exe). Replace the <input_file> with your file name and the </path/to/dir/> to the path to the directory you want to have your output (the output directory option is opional). You can use the wildcard * as the input file, which would convert all the files in the directory to csv.

How to open (import) .CSV into Excel using CMD

I found a sort-of answer here:
https://superuser.com/questions/730249/run-command-to-open-csv-file-in-excel
But it's not enough to simply use excel to open my .CSV file; I want to import the .csv data into the excel worksheet (I can do it using the wizard built into excel if I open the program manually), but I want to do this all strictly using CMD. I have previously generated a .csv file using SQLCMD but I couldn't generate it into an excel file, so I'm trying to do this all in 2 steps instead.
I found a powershell version of what I need here: How to export a CSV to Excel using Powershell.
I made my own adjustments to fit my needs, but it worked perfectly! And I learned how to call this powershell script from my cmd/batch file so I think this will work.

.dat file how to create one based on excel document

I have a .csv file in my matlab folder with 38 columns and about 48 thousand entries. I was hoping on using the findcluster gui but it only accepts .dat files.
How do I create a .dat file in matlab or specifically how do I convert the .csv file into a .dat file that can be used by the matlab fcm clustering tool?
example of csv:
how would I go about creating a data file for this kind of information?
The only documentation I could find about the file format was
The data set must have the extension .dat. For example, to load the data set,
clusterdemo.dat, type findcluster('clusterdemo.dat').
I checked clusterdemo.dat and found that the data is stored in ASCII format. Therefore, try
a = csvread('data.csv');
save 'data.dat' a -ASCII
Just rename xxx.csv to xxx.dat. This worked for me.
you should try changing extension.For changing extension you can go to folder settingļƒ and in view where we show hidden fileā€¦uncheck the hide extension for known files and now you can change the extension of any file by renaming it.
Because
There really isn't such a thing as 'dat' format, a 'dat' file is just a text file, it could theoretically have any extension you want.It could also be delimited however you want/need, it all really depends on what you are trying to achieve.
ie what are you going to use this file for?
If it's for use with another application then the requirements of that application will probably dictate how it's delimited/structured etc.
OR simply you can save the file from the excel as .csv and then later can change the extension.
It worked for me.

use OpenOffice Calc to open Excel files and convert to CSV or Tab-delimited

Is there any type of automation available where I can use OpenOffice Calc to open Excel files and convert them to CSV or tab-delimited files?
I'm currently using PHPExcel to open the files and iterate through them and import each row into a database but have begun to run into memory issues with large files and need another alternative.
These are xls and xlsx files so it has to work for all of them.
If there is, how would I go about programming this in PHP?
If you have other alternatives, please feel free to suggest them.
OpenOffice can be run in server mode and used to convert files between a number of supported formats.
I have used this mainly with Java thru the JODConverter library available at http://www.artofsolving.com/opensource/jodconverter
A quick websearch brought up http://sourceforge.net/projects/phopo-org/ which claims to be a PHP implementation

Resources