Message Boards Message Boards

0
|
4867 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Access a specific element of a data array?

Hi This must be a very simple question but I could not find the answer in the Documentation Center. I am importing data from a file that contains two columns of numbers:

data = Import["myfile.txt"]

How can I access a specific element in the data array, e.g. column 1, row 3?

POSTED BY: Lev Dorosinskiy
4 Replies

Thank you, that has worked!

POSTED BY: Lev Dorosinskiy
Posted 5 years ago

Looks like the file has been imported as a single String rather than a List of lists. Also looks like the columns in the file are TAB separated. If so, try

data = Import["Data1.txt", "TSV"]
data[[2,2]]
POSTED BY: Rohit Namjoshi

Thank you but that does not work. The array 'data' must be having a different structure.

I am attaching two images which show the output for data and for Part:

Attachment

Attachment

Attachments:
POSTED BY: Lev Dorosinskiy
Posted 5 years ago

You can use Part.

E.g.: data = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; data[[3,1]] 7

POSTED BY: chris slinger
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract