How do I import a complicated .txt file?

2 ビュー (過去 30 日間)
Hans Franz
Hans Franz 2018 年 1 月 7 日
回答済み: Kris Fedorenko 2018 年 1 月 9 日
Hi everyone, I have I quite difficult .txt to Import into Matlab. There are header lines after every segment. The first rows of the file look like this:
2017-10-17T09:02:03,099091678+00:00
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:07 --:--:-- 0
100 1024 100 1024 0 0 135 0 0:00:07 0:00:07 --:--:-- 135
2017-10-17T09:02:10,957307712+00:00
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 15 100 15 0 0 84 0 --:--:-- --:--:-- --:--:-- 84
2017-10-17T09:02:11,205189925+00:00
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 10240 100 10240 0 0 55063 0 --:--:-- --:--:-- --:--:-- 55351
2017-10-17T09:02:11,458842315+00:00
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 15 100 15 0 0 135 0 --:--:-- --:--:-- --:--:-- 136
end
I want to import this into a structure which should look like this:
Import.date
Import.time
Import.Total
Import.Received
Import.Xferd
...
Actually I have no idea how to import this... Because of the complexity, importdata does not work...
I am thankful for every answer, thanks!

回答 (1 件)

Kris Fedorenko
Kris Fedorenko 2018 年 1 月 9 日
I would suggest copy-pasting each segment into a separate Excel file and using the "Text to Columns" functionality:
Then it should be easy to import each segment with "readtable" or Import Tool.
If the number of segments is prohibitive for this kind of manual processing, you can also copy-paste the entire file to Excel, and then use Import Tool to disregard the text.

カテゴリ

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