i have a datatable:
var dt = new DataTable();
dt.Columns.Add(new DataColumn("specimen", typeof(string)));
dt.Columns.Add(new DataColumn("batch", typeof(string)));
dt.Columns.Add(new DataColumn("position", typeof(string)));
the data looks something like this inside of it:
Spec. ID Batch/Pos. position
AA00721 16785 3
AA00722 16785 2
AA00734 16785 3
AA00735 16860 6
AA00737 16862 4
AA00738 16860 7
AA00739 16863 5
AA00740 16860 9
AA00741 16861 7
AA00742 16861 0
AA00743 16861 5
for each unique batch, i need to create a file with all the specIDs and positions.
for example file 16785.txt would look like this:
AA00721 3
AA00722 2
AA00734 3
how would i loop through this datatable to create separate files>? please assume that the batch numbers are not sorted
If you would like to utilize a LINQ method, I would group your data on the batch and then just iterate through the groups.