Message Boards Message Boards

0
|
4209 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Importing a matrix from a txt file?

Posted 3 years ago

Hello everyone. I am trying to read a .mat file created using another language, it's dimensions are 50*10. The code I am using is

Clear["Global`*"]
SetDirectory[NotebookDirectory[]];

dataText = Import["listOfUVValuesLite.txt", "Table"];

However, once I load this, dataText becomes a vector of dimenson 50, being each element a series of 10 elements. Hoever, mathematica doesn't detect each element of dataText as a row, but as a single element. If I try to write dataText[[3, 1]] I get the whole row and dataText[[3, 2]], an error.

Can someone please explain to me how to get a 50X10 or 10X50 matrix form listOfUVValuesLite.txt? I will attach it so test can be made.

Best regards. Jaime.

Attachments:
POSTED BY: Jaime de la Mota
2 Replies
Posted 3 years ago

Hi Jamie,

The data is CSV so

data = Import["~/Downloads/listOfUVValuesLite.txt", "CSV"]

Dimensions@data
(* {50, 10} *}
POSTED BY: Rohit Namjoshi

Thank you. This works fine!

POSTED BY: Jaime de la Mota
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