How do I import a complicated .txt file?
조회 수: 2 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!