Skip to main content
Question Protected by xzczd
Improved formatting
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

... ($N-4$ additional row entries)

Where the numeric values in each row are separated by a space. HowHow would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

{ 
  {-17.071, 137.567, 16.554, 0.65},
  {-16.873, 136.138, 16.934, 0.7},
  {-15.397, 135.738, 16.894, 0.7},
  {-14.7, 135.982, 15.9, 0.6},
  ...
}

Trying:Evaluating

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

Where the numeric values in each row are separated by a space. How would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

Trying:

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

Where the numeric values in each row are separated by a space. How would I read this matrix in, and parse it in the following manner:

{ 
  {-17.071, 137.567, 16.554, 0.65},
  {-16.873, 136.138, 16.934, 0.7},
  {-15.397, 135.738, 16.894, 0.7},
  {-14.7, 135.982, 15.9, 0.6},
  ...
}

Evaluating

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

added 64 characters in body
Source Link
Roger Harris
  • 1.5k
  • 1
  • 13
  • 20

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

HowWhere the numeric values in each row are separated by a space. How would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

Trying:

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

How would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

Trying:

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

Where the numeric values in each row are separated by a space. How would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

Trying:

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.

Source Link
Roger Harris
  • 1.5k
  • 1
  • 13
  • 20

Importing a matrix from a text file

I have a $4 \times N$ matrix in a .txt file of the form:

-17.071 137.567 16.554 0.65

-16.873 136.138 16.934 0.7

-15.397 135.738 16.894 0.7

-14.7 135.982 15.9 0.6

... ($N-4$ additional row entries)

How would I read this matrix in, and parse it in the following manner:

{{-17.071,137.567,16.554,0.65}, {-16.873,136.138,16.934,0.7},{-15.397,135.738,16.894,0.7},{-14.7,135.982,15.9,0.6},...}?

Trying:

Import[PATH\\MATRIX.txt]] 

Only returns the printed contents of the file.