0

In GNU OCTAVE, I have input file like this, and i have to read only first and second columns and store to variable. . This is only small part of my file. When so, i can not read whole file and cut a column that i need. I should read only what i need, to save a memory.

1 2 1 1015887601
1 3 1 1015887601
1 4 1 1015887601
1 5 1 1015887601
1 6 1 1015887601
1 7 1 1015887601
1 8 1 1015887601
1 9 1 1015887601
2 10 1 1015887601
2 11 1 1015887601
2 12 1 1015887601
3 13 1 1015887601
3 14 1 1015887601
0

1 Answer 1

1

Check out dlmread. Octave has the same function, it seems to do what you need.

Something like:

dlmread('yourfile.txt', ' ', 'A1..Bn') % replace n with the size of the file
Sign up to request clarification or add additional context in comments.

5 Comments

Or you can use the range parameter which is might be more appropriate. M = dlmread(filename, delimiter, range)
Why do you not add the link to Octave's dlmread() instead of Matlab's?
@Pokey McPokerson how can i get file size to replace n
Hi kkuilla, I used the Matlab link because it was very descriptive and had nice examples. The functions work exactly the same way as far as I can tell.
TNeykov, it seems like your data is fairly predictable? You could keep reading in blocks until you encounter a 0. Or if you're expecting 0s, you can set the "empty value" field to -1 (see the Octave function link in the updated answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.