I'm currently trying to code a For Loop that includes StringDrop:
For[i=0, i<=100,i++, Print[StringDrop[list[[i,1]],4]]]
Where list is an array and the first column (which I'm trying to extract), is called node0, node1,...
I'm getting
Part::partd: Part specification <<1>> is longer than depth of object." and "StringDrop::strse: String or list of strings expected at position 1 in StringDrop[{{node0,node1 0.04,node8 11.11,node14 72.21},{node1,node46 1247.25,node6 20.59,node13 64.94},{node2,node66 54.18,node31 166.80,node45 1561.45},{node3,node20 133.65,node6 2.06,node11 42.43},<<3>>,{node7,node50 478.14,node9 3.15,node10 5.85},{node8,node69 577.91,node11 7.45,node12 3.18},{node9,node70 2454.28,node13 4.42,node20 16.53},<<90>>}[[0,1]],4].
Any thoughts on why this isn't working? Thanks
EDIT:
For[
i = 0, i <= 100, i++,
node = StringDrop[list[[i, 1]], 4] ;(*This is the node in question*)
Here is the list (first few entries):
TableForm[{{"node0", "node1 0.04", "node8 11.11", "node14 72.21"}, {
"node1", "node46 1247.25", "node6 20.59", "node13 64.94"}, {
"node2", "node66 54.18", "node31 166.80", "node45 1561.45"}, {
"node3", "node20 133.65", "node6 2.06", "node11 42.43"}, {
"node4", "node75 3706.67", "node5 0.73", "node7 1.02"}, {
"node5", "node45 1382.97", "node7 3.33", "node11 34.54"}, {
"node6", "node31 63.17", "node9 0.72", "node10 13.10"}]
i = 0
toi=1
as Mathematica index starts from 1. And try to do it withoutTableForm
as that is a wrapper. And changei <= 100
toi <= Length@list
. Also there are better ways to do this withoutFor
using more functional programming. $\endgroup$First /@ alist
get you what you need? wherealist
is your data without theTableForm
. $\endgroup$