c# - Writing list to CSV file -
i have list of list of int called nn write csv file this:
list<list<int>> nn = new list<list<int>>();
the nn list:
1,2,3,4,5,6 2,5,6,3,1,0 0,9,2,6,7,8
and output csv file should this:
1,2,0 2,5,9 3,6,2 4,3,6 5,1,7 6,0,8
what best way achieve that?
if there better representation recommend instead of nested list i'll glad know.
(the purpose each list of int weights between last , next layer in neural network).
here how can it:
list<list<int>> nn = new list <list<int>> { new list<int> {1,2,3,4,5,6}, new list<int> {2,5,6,3,1,0}, new list<int> {0,9,2,6,7,8} }; //get expected number of rows var numberofrows = nn[0].count; var rows = enumerable.range(0, numberofrows) //for each row .select(row => nn.select(list => list[row]).tolist()) //get row data columns .tolist(); stringbuilder sb = new stringbuilder(); foreach (var row in rows) { sb.appendline(string.join(",", row)); } var result = sb.tostring();
Comments
Post a Comment