Message Boards Message Boards

GROUPS:

Importing a matrix from a txt file?

Posted 4 months ago
865 Views
|
2 Replies
|
1 Total Likes
|

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:
2 Replies

Thank you. This works fine!

Posted 4 months ago

Hi Jamie,

The data is CSV so

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

Dimensions@data
(* {50, 10} *}
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