[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Transform list into matrix
From: |
PhilipNienhuis |
Subject: |
Re: Transform list into matrix |
Date: |
Tue, 31 Jan 2012 14:01:57 -0800 (PST) |
AJ wrote
>
> Hi everybody!
>
> I am new in using Octave. I have been browsing list as to look for a
> solution to my problem, related to matrices, but I have not found an
> example helping me. My question is if it is possible to construct a matrix
> from one net list (like Pajek .NET). This is one example which I have:
>
> A B 5
> A F 7
> A K 4
> A X 8
> B D 1
> B P 1
> B Z 9
> C L 6
> C O 2
> ...
>
> The real list have around 2 million of rows and I would have to load from
> a TXT file. Is there a easy way to do all this?
>
>
2 million rows, 6 or 7 bytes per line incl. EOL, means about 12-14 MB.
Nothing much.
After parsing the file into tokens, you'll have maybe 100 MB or so in memory
(depending on chosen data type), still shouldn't be problematic although
Octave may become a bit slow.
I wouldn't know how to properly parse a Pajek file, but if you want your
data file in a 3 X N cell array (N = number of rows in file) from which you
can do further processing, you could easily do in Octave-3.6.0:
fid = fopen ("put_Pajek_file_name_here");
C = textscan (fid, "%s %s %s", "collectoutput", 1);
fclose (fid);
(of course assuming all lines of your data file have the same layout).
(BTW I hit some strread.m bugs while trying, I've added a fix to the bug
tracker #35418)
Philip
--
View this message in context:
http://octave.1599824.n4.nabble.com/Transform-list-into-matrix-tp4340505p4346049.html
Sent from the Octave - General mailing list archive at Nabble.com.