From: André F. <a.f...@gm...> - 2015-10-16 08:38:46
|
I have been using Maxima now for a few months and I am getting comfortable with it. But I have problem now with some calculations I have to do. I am reading in data from hundreds of external files. Each file has a header that looks like this /* RGBident=000000 */ /* Press=1.018119e+00 */ /* Density=1.000000e+00 */ /* AutoCalib=0 */ /* Temp=2.228929e+02 */ /* Log=1515870810 */ /* Length=1.000000e+01 */ /* Name=(null) */ /* File: absorbed_pre.csv */ currently I ignore the header completely by using this script here /* [wxMaxima: subsect start ] Data files with comments at the top [wxMaxima: subsect end ] */ /* [wxMaxima: input start ] */ intNumberOfReffiles : length(DataRefFile); /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ read_commented_dataFile(fileName) := block([NumberofComments, SPEData1, SPEDataLength1, h2, i, n, log10absorption], errcatch( kill(h2), SPEData1 : read_nested_list( fileName), SPEDataLength1 : length(SPEData1), n : 1, for i:1 while ((numberp(SPEData1[n][1]) = false) and (n < SPEDataLength1)) do (n : n + 1), NumberofComments : n - 1, SPEDataLength1 : SPEDataLength1- NumberofComments, print("Comment lines: ", NumberofComments), h2[x, y] := if y = 2 then SPEData1[x + NumberofComments][2] else SPEData1[x + NumberofComments][1], log10absorption : genmatrix (h2, SPEDataLength1, 2), kill(h2), log10absorption)[1])$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ i : 1; /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ for n : 1 thru intNumberOfReffiles do ( if errcatch( Data[i] : read_commented_dataFile(concat(workDir, DataRefFile[n]))) = [] then ( print("ERROR in: ", DataRefFile[n]) ) else ( DataFile[i] : DataFile[n], print(n, " of ", intNumberOfReffiles, ": ", DataFile[i], " - ", length(Data[i]), " First cell:", Data[i][1]), NumberOfReffiles : i, i : i+1 ) )$ /* [wxMaxima: input end ] */ /* [wxMaxima: input start ] */ NumberOfReffiles; /* [wxMaxima: input end ] */ but now I need to read the numbers in the header into Maxima for calculation purposes. Any suggestions? |