How to load txt file with a known number of rows with different lengths of columns??

조회 수: 1 (최근 30일)
Hey all,
I tried loading my txt file that has different number of columns usnig different commands and down i will state each one with its problem:
1] load: doesn't work for different number of columns.
2] importdata: introduced in my txt two additional lines!!
3] dlmread: padded my data with zeros to make all columns the same length!
Can anyone suggest another command!! dlmread seems the best out of theses three commands I tried, but my data is very sensitive specially to zeros!!even if I tried to eliminate them, there is no way I can know whether this zero is one of my data or the padded one!!
  댓글 수: 2
Jan
Jan 2012년 11월 21일
편집: Jan 2012년 11월 21일
  • What does "introduced two addional lines" mean?
  • Why are the data padded by dlmread to make the columns the smae length?! You've said, that there is a different number of columns, but do the columns have a different length in addition?!
Please show a minimal example of a possible file, and explain the wanted output format. DLMREAD creates a matrix, and matrices must be rectangular. Therefore the padding is expected and wanted.
Yasmin Tamimi
Yasmin Tamimi 2012년 11월 21일
Sorry I haven't made my question clear! I am having a txt file with 10 rows but the length of the columns in each row is different. By "introduced two additional lines" I mean instead of having of having only two rows now I'm getting 12 rows!! And now when the data is padded how can I know which one is the data and which one is the padded?! How can I just load and read the data without padding it with anything?

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

답변 (1개)

Jan
Jan 2012년 11월 21일
편집: Jan 2012년 11월 21일
What about textscan? It appears as tag already, but not in the text of the question.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by