I read this post here, and played a bit with the Import function, so I now have my data imported from xlsx file, which say is a 5 by 10 Dataset.

After using

tmp = Import["myfile.xlsx", {"Dataset", 1}, HeaderLines -> {1, 1}]

now it's in Dataset format. But only the row names can be used as Association?

What's the best way to effiently transfer all the row/col names, and make them useable in Mathematica?


  • 1
    $\begingroup$ You can simply Import file as data, and then use AssociationThread: imp = Import["myfile.txt"]//First; dataset = Dataset[AssociationThread[imp[[2 ;;, 1]] -> (AssociationThread[imp[[1, 2 ;;]] -> #] & /@ imp[[2 ;;, 2 ;;]])]]. I assume that first row and first column (starting from 2nd row) have names, then you can address values like dataset["row-name","column-name"]. $\endgroup$ – Alx Dec 31 '19 at 3:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.