I have a file whose data read as {{0,:,1,2,3;},{1,:,0,164,165;},{2,:,0,3,167;},{3,:,0,2,166;},.., {"$$"}}
I have to format this data into a matrix. There is also a first three line that I omitted for clarity. I was trying to remove the these lines by hand, but I found it cumbersome for each file. So, the reading of the data should be from the fourth line onward.
In this above data {{0,:,1,2,3;},.., {"$$"}}
, the first entry tells us the lattice site, and after semi-colon :
, it shows to which this lattice site is connected. It is one-dimensional data. Moreover, we should ignore the last part (or last line) in the data, i.e. {"$$"}
. Essentially, the first-three and the last lines are to be ignored while reading the data. The truncated data can be found here pastebin.
For instance, in this entry {{0,:,1,2,3;}
, the lattice site 0
is connected to the lattice site 1
, 2
, and 3
, and so on and so forth. Hence the matrix entry coming from this case would look like {{0,1,1,1,...,0},...}
The total lattice sites in the above case is 165, so the matrix would be 165 $\times$ 165
My MWE:
data=Import["file.dat"];
data[[4,2]]=1;
data[[4,3]]=1;
data[[4,4]]=1;
Unfortunately, I have no idea how to proceed further. I found myself very ignorant. I searched through the Mathematica.stack but could not follow the answers. I have never done this. Even if a full answer is not given but a hint, I will try to reconstruct the answer or MWE—apologies for the ignorance.
{{0,:,1,2,3;}
maps to{{0,1,1,1,...,0},...}
. What are the...
? What does{1,:,0,164,165;}
map to? $\endgroup${{0,1,1,1,...,0},...}
means the site at0
is not connected to any other lattice sites after the third one, hence the zeroes to denote it. $\endgroup$