conversion .txt to .xls

hello, please, how can I convert a txt file to an Excel file

3 件のコメント

Ahmed BOULMANE
Ahmed BOULMANE 2016 年 4 月 25 日
編集済み: Ahmed BOULMANE 2016 年 4 月 25 日
please, i have to know how can i do that today
Stephen23
Stephen23 2016 年 4 月 27 日
編集済み: Stephen23 2016 年 4 月 27 日
Please upload an example file so that we can actually test our code on something.
Ahmed BOULMANE
Ahmed BOULMANE 2016 年 4 月 28 日
here is the file,

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 25 日

0 投票

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 件のコメント

Ahmed BOULMANE
Ahmed BOULMANE 2016 年 4 月 25 日
in fact, I have a file like this
xxxxxxxxxtextxxxxxxxxxx
xxxxxxxxxtextxxxxxxxxxx
xxxx xxxx xxxx xxxx
545 454 541 424
421 457 87 65
xxx xxx xxx xxx xxx xxx xxx xxx
54 14 54 45 42 47 74 54
214 584 54 54 7 87 9 87
xxxxxxxxxxxxxtextxxxxxxxxxxx
can you help me!! I am a beginner in matlab Thank you
Walter Roberson
Walter Roberson 2016 年 4 月 25 日
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
Ahmed BOULMANE 2016 年 4 月 26 日
no, it was just an example, the file structure changes from case to another I showed it like that to tell you that the number of columns changes
Ahmed BOULMANE
Ahmed BOULMANE 2016 年 4 月 27 日
i can't find a solution until now !! help me please
Walter Roberson
Walter Roberson 2016 年 4 月 27 日
Is it always exactly two rows of numbers per group? Do you always have exactly two such groups?
Ahmed BOULMANE
Ahmed BOULMANE 2016 年 4 月 28 日
I have always the same number of group, but the number of row and column change
Walter Roberson
Walter Roberson 2016 年 4 月 28 日
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.

この質問は閉じられています。

タグ

質問済み:

2016 年 4 月 22 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by