Skip to main content
2 of 3
added 172 characters in body
Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33

How to Import[...] a datafile from a file created by OpenAppend[...]

I created a datafile as follows:

ESTgrowth = FileNameJoin[{"Filepath", "ESTgrowth"}];
open = OpenAppend[ESTgrowth];
Write[open, newdata];  (*"newdata" is a list of data appended to "ESTgrowth" *)
Close[open];

This code appends data stream as follows:

{-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}

Then I tried to import the data file to present it using TableForm[...]. Of course,

Import[ESTgrowth, "Table"]

would NOT work because the data stream consists of lists of data only. My question is how to automatically put the data stream into the following format:

{ 
  {-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}
}

for TableForm[...] to work as expected.

Screenshot of my dataset with Extra commas placed in fixed positions in each row.

enter image description here

Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33