Wolfram mathematica 从Mathematica中的文本文件获取矩阵

Wolfram mathematica 从Mathematica中的文本文件获取矩阵,wolfram-mathematica,Wolfram Mathematica,将文本文件转换为矩阵的最简单方法是什么?它每行有一行,其中O表示0,X表示1我首先将该文本保存在一个文件tmp.txt中 In[180]:= words = ReadList["~danl/tmp.txt", Word]; vals = Map[Characters, words] /. {"O" -> 0, "X" -> 1}; In[182]:= vals[[1]] Out[182]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

将文本文件转换为矩阵的最简单方法是什么?它每行有一行,其中
O
表示
0
X
表示
1
我首先将该文本保存在一个文件tmp.txt中

In[180]:= words = ReadList["~danl/tmp.txt", Word];
vals = Map[Characters, words] /. {"O" -> 0, "X" -> 1};

In[182]:= vals[[1]]
Out[182]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
丹尼尔·利奇布劳
Wolfram Research

您使用什么语言?您应该使用数字键盘:)等等,您可以使用URL作为参数来导入?多酷啊?恭喜你跑了10公里!我必须找到一个我还没有投票给你的答案:)
$url = "http://hyperpublic.com/challenge2input.txt";
StringCases[Import[$url, "Lines"], {"O" -> 0, "X" -> 1}]