I want to implement the option to import data from Excel and then the ability to trim this data in order to fit the needs.
The import from Excel: (source)
Button["import from Excel", Module[{file},
file = SystemDialogInput["FileOpen", {NotebookDirectory[] <>"data\\",
{"Excel files" -> {"*.xls;*.xlsx;*.xlsm"}}}];
If[file != "$Canceled", rawdata = Flatten[Import[file, "xls"], 1]]],
Method -> "Queued"]
As an example rawdata
should be:
rawdata={{"n", "t(n)", "t(n)/t(n-1)", "Ø(t(n)/t(n-1))"}, {20., 1.15, "", 1.30081},
{21., 1.54, 1.33913, ""}, {22., 2.43, 1.57792, ""}, {23., 3.29, 1.35391, ""},
{24., 4.26, 1.29483, ""}, {25., 5.43, 1.27465, ""}, {26., 7.18, 1.32228, ""},
{27., 9.2, 1.28134, ""}, {28., 12.04, 1.3087, ""}, {29., 15.68, 1.30233, ""},
{30., 20.34, 1.29719, ""}, {31., 26.11, 1.28368, ""}, {32., 33.09, 1.26733, ""},
{33., 42.67, 1.28951, ""}, {34., 53.56, 1.25521, ""}, {35., 68., 1.2696, ""},
{36., 84.51, 1.24279, ""}, {37., 106.95, 1.26553, ""}, {38., 136.85, 1.27957, ""},
{39., 172.71, 1.26204, ""}, {40., 215.64, 1.24857, ""}}
Now i imagined the possibility to transpose and trim this data with something like this:
Row[{Checkbox[Dynamic[transpose]], TextCell[" transpose"]}]
Dynamic[TableForm[data = If[transpose, Transpose[rawdata], rawdata]]]
Dynamic[TableForm[Join[{Prepend[ConstantArray[Checkbox[True], Length@data[[1]]], ""]},
Map[Prepend[#, Checkbox[True]] &, data]]]]
Of course i want to merge the 2 TableForms into one, but my attempt to do so has failed:
Dynamic[TableForm[Function[list, If[transpose, Transpose[list], list]][Join[
{Prepend[ConstantArray[Checkbox[True], Length@data[[1]]], ""]},
Map[Prepend[#, Checkbox[True]] &, data]]]]]
My goal:
The checkboxes near each row/column shall deselect that row/column in the data and grey it out in the TableForm for better clarity. After pressing a confirmation button the data is saved as selected.
My Problem:
Right now the Checkboxes do not contain a variable (because i was not able to automatically assign variable names with a command like StringJoin <>
) and so i was not able to read the values of the checkboxes.
And the merging of the two TableForms.
If anybody has an alternative solution i'm open for suggestions.