How to read rows and headers separately into a dataset?

Suppose that the information for constructing a dataset is split over two separate files: one file contains the numeric data, and a second file contains the names of the columns.

Is there a simple way to create a dataset from these two separate files?

2 Answers

columnames=CharacterRange["a","h"];
data= RandomInteger[9,{20,8}];

ds=Dataset[AssociationThread[columnames->#]&/@data]


OK, I found a second way. Like kglr's solution, this one also uses AssociationThread, but applies it only once:

makeDataset[columns_, columnLabels_] := Module[{labeledColumns, records},
labeledColumns = AssociationThread[columnLabels, columns];
records = Transpose[labeledColumns, AllowedHeads -> All];
Dataset[records]
];


The importer can be easily written in terms of makeDataset:

readDataset[datafile_, headerfile_] := Module[{columns, columnLabels},
columns = Transpose[Import[datafile]];
columnLabels = First[Import[headerfile]];
makeDataset[columns, columnLabels]
];