How to export data to excel

7 ビュー (過去 30 日間)
Javier Martinez
Javier Martinez 2016 年 7 月 1 日
編集済み: Javier Martinez 2016 年 7 月 1 日
How can I export data to Excel, if I have the following .txt file, separated with commas.
HTSGW, [m], 197901010000, 197901010000, 0.000 HTSGW, [m], 197901010000, 197901010300, 0.220 HTSGW, [m], 197901010000, 197901010600, 0.420 HTSGW, [m], 197901010000, 197901010900, 0.560 HTSGW, [m], 197901010000, 197901011200, 2.190
  1 件のコメント
José-Luis
José-Luis 2016 年 7 月 1 日
編集済み: José-Luis 2016 年 7 月 1 日
Why go through Matlab? If you have a text file, why don't you just open it in excel and get rid of the middle man?
Oterwise, there's always xlswrite().

サインインしてコメントする。

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 7 月 1 日
f = fopen('yourtextfile.txt');
c = textscan(f,'%s %s %s %s %s','delimiter',',');
fclose(f);
xlswrite('nameyourxlsxfile.xlsx',[c{:}])
  2 件のコメント
Javier Martinez
Javier Martinez 2016 年 7 月 1 日
Thank you very much!
Javier Martinez
Javier Martinez 2016 年 7 月 1 日
編集済み: Javier Martinez 2016 年 7 月 1 日
The code works fine. It would be grateful if you could also help with this: Once I have the excel file, the last column shows numbers like 2.190 (which actually corresponds to 2,190 meters) however excel reads directly the number 2.190 (two thousand hundred and ninety) which is false. What can I do to avoid this, I have been looking for changing points into commas, however I cannot solve that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by