How to skip lines while loading text (.txt) files ?

zghsryfkmgcbg
fnmfmn fhmfmfjmfm njdmf
ddgjd
fgjnfm nm ncncgn
fhjmvbnmvnmhgmfh
fnmhm
fdhmdtmgkmuykmnf
fjrykj fjryjtukmfryfk
ghugfhjgkjhklhfjfgjfjfh
_1_ 3454
_2_ 4667
_3_ 5645
_4_ 4564
_5_ 76457
_6_ 4574
_7_ 46574
_8_ 6574
_9_ 746
_10_ 4
_11_ 47568
_12_ 578
_13_ 87
_14_ 56
_15_ 36
_16_ 473
_17_ 636
_18_ 3
_19_ 56

댓글 수: 3

Stephen23
Stephen23 2018년 1월 27일
@ Md Fakhra Alam Faisal: what lines do you want to skip? What tool are you using? Do you want to import any of the header lines? Is the number of header lines always the same?
1 3454
2 4667
3 5645
4 4564
5 76457
6 4574
7 46574
8 6574
9 746
10 4
11 47568
12 578
13 87
14 56
15 36
16 473 17 636
18 3
19 56
Here i want like two columns
Stephen23
Stephen23 2018년 1월 27일
Is the number of header lines always the same?"
Does the numeric data really have underscores around it?
(note: it would be much simpler if you just uploaded a sample file).

댓글을 달려면 로그인하십시오.

 채택된 답변

Md Fakhra Alam Faisal
Md Fakhra Alam Faisal 2018년 1월 27일

2 개 추천

Thanks a lot, @Stephen Cobeldick I've found the solution. The problem was simply skipping some header line and read the rest body by two column. here the script now I am using
AAA = fopen('XXX.txt', 'rt'); % File Name XXX.txt
BBB = textscan(AAA, '%f %f', 'HeaderLines',9); % To skip 9 Header line
Column_1=BBB {1,1};
Column_2=BBB {1,2};

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by