conversion .txt to .xls
Info
This question is closed. Reopen it to edit or answer.
Show older comments
hello, please, how can I convert a txt file to an Excel file
3 Comments
Ahmed BOULMANE
on 25 Apr 2016
Edited: Ahmed BOULMANE
on 25 Apr 2016
Ahmed BOULMANE
on 28 Apr 2016
Answers (1)
Walter Roberson
on 25 Apr 2016
0 votes
Depending on the format of the text file, there are different ways of reading it. Sometimes it is enough to load() the file. Sometimes you need textscan(). Sometimes you need to do a log of work with parsing it. Try the import wizard; if it is able to handle the file then it can generate code for you.
If you end up with a numeric matrix, use num2cell() to convert it to cell array.
When you have a cell array, use xlswrite() to save it as xls file.
Note: if you are running on OS-X or Linux, or on MS Windows without Excel installed, then use the File Exchange contribution xlwrite() instead of xlswrite()
7 Comments
Ahmed BOULMANE
on 25 Apr 2016
Walter Roberson
on 25 Apr 2016
You show exactly two rows of numbers after each of the x headings. Is it always exactly two rows? Do you always have exactly two groups of such headings and numbers? Is the number of numbers in each row always exactly 4 for the first group and always exactly 8 for the second?
Ahmed BOULMANE
on 26 Apr 2016
Ahmed BOULMANE
on 27 Apr 2016
Walter Roberson
on 27 Apr 2016
Is it always exactly two rows of numbers per group? Do you always have exactly two such groups?
Ahmed BOULMANE
on 28 Apr 2016
Walter Roberson
on 28 Apr 2016
I looked at your sample file with an editor. The difficulty of reading it in is going to depend upon exactly what data you want to extract out and into what variables. The difficulty is greatly increased if the "TOTAL =" data has to be extracted into the same variable as what it is being totaled.
Please show a sample output, indicating which values need to end up in which variables.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!