I'm new here and with MathematicaMathematica, too. I want MathematicaMathematica to import data from a txt file (it hasthas one column of data). This entrysThese entries are z-values. From this I want to make a matrix - 508 entrysentries make one row, 308 rows in total. And And then I want it to be exportedexport it to a dat file.
Here is my code:
data = Import["D:\Data\Mathematica\Convert_data\rawdata.txt", "Table"]; Flatten[data]; carray = ConstantArray[1, {308, 508}]; For[j = 1, j < 309, j++, For[i = 1, i < 508, i++, carray[[j, i]] = data[[(j - 1)*508 + i]]]]; Export["test.dat", carray, "Table"]
data = Import["D:\\Data\\Mathematica\\Convert_data\\rawdata.txt", "Table"]; Flatten[data];
carray = ConstantArray[1, {308, 508}];
For[j = 1, j < 309, j++,
For[i = 1, i < 508, i++, carray[[j, i]] = data[[(j - 1)*508 + i]] ]
];
Export["test.dat", carray, "Table"]
It does nearly everything it is supposed to do. It creates a matrix as I want it to, but all the entrysentries are in curly braces. I think the problem is right at the beginning, when I import the data, all the entrysentries are in a curly brace, and all these braces are within a common brace. I tried to get rid of the single curly braces around each value with "Flatten", but it doesn't do anything.
The txt file I start with looks like this:
1.598669e+000
1.570571e+000
1.600274e+000
1.513271e+000
1.549999e+000
1.426268e+000
1.197772e+000
....
1.598669e+000
1.570571e+000
1.600274e+000
1.513271e+000
1.549999e+000
1.426268e+000
1.197772e+000
....
It has many entrysentries, so I dontdon't show all of them here.