0
$\begingroup$

I have a ReadList of just some real numbers, called data. I'm trying to extract the data of specific columns from my list. When I execute the following

data[[All,1]]

I get this error:

Part::partd: Part specification {-11.7056,-1.82099,8.23499,18.509,28.6437,-6.42392,2.4783,11.4386,-11.117,<<34>>,-7.02967,-8.13113,437.567,446.853,456.65,467.2,476.809,<<951>>}[[All,1]] is longer than depth of object.

However, whenever I type data[[All,0]] , the output is just the word "Real" over and over again. I assume it's telling me whether each value in the list is real or nonreal. I expected that this would either actually read me a column from my list or just give me the same error as before. Why is this different?

Can anyone tell what's going on? Is there a different way to extract a column of data from this list? Is it possible the list isn't actually ordered into columns at all?

$\endgroup$

closed as off-topic by Mike Honeychurch, m_goldberg, Henrik Schumacher, Coolwater, LCarvalho Feb 8 '18 at 19:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Mike Honeychurch, m_goldberg, Henrik Schumacher, Coolwater, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

3
$\begingroup$

data[[All,1]] refers to the first element of all elements from data. Since elements of data aren't lists, they have no first elements at all. [[All,0]] refers to the type of data, which is a real number and not a list.

Your data is a list of real numbers, and not 2D array. You can check that by Dimensions[data].

$\endgroup$
0
$\begingroup$

UsingReadList reads each line in a file and returns a list of them. This can sometimes lead to an array of data which is not a matrix. In such cases data[[All,i]], where i is a secondary dimension index at which we could expect to have a value, could yield an error that you are writing about. In such cases even using a Dimensions[data] will not help, because it will just tell you number of the rows.

I am talking about this:
NotAMatrix = {{-1, -2, -8}, {-5, -45}}; TableForm[%] Dimensions[NoMatrix] NoMatrix[[All, 3]]

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.