I often get a data table with column names and row names. For example:
Gene_Name ID CHR Sample_1 Sample_2 Sample_3 ...
Itm2a NM_00134 chrX 0.00 1.23 2.45 ...
Fam109a NM_02342 chr7 1.44 4.44 2.14 ...
... ... ... ... ... ... ...
I'd like to divide it into 4 blocks, namely the data block (with all the numeric data reads), column names, row names and corner names. Currently I usually do something like this:
rw = Import["table.csv"];
colnames = rw[[1 ;; 1, 4 ;;]];
rownames = rw[[2 ;;, 1 ;; 3]];
cornernames = rw[[1 ;; 1, 1 ;; 3]];
data = rw[[2 ;;, 4 ;;]];
which is quite clumsy and feels not "mathmatica". Can anyone do better?
Part
is fast in Mathematica so there's no wrong in using it. If you're looking for something more compact you can get away with just onePart
:{cols, rows, corners, data} = Import["table.csv"][[{span 1, span 2, span 3, span 4}]]
$\endgroup$