I can’t work out how to pull data out of a .txt file and put it into a .csv file (2 columns and x rows). I’ve made a simplified version below.
The length of the txt file is dynamic but the output will always be 2 columns
I thought that I should build a datatable and then feed the data into it but I don’t seem to manage, no matter what I try. Any help would be really appreciated. Thanks very much.
Mock-up .txt file
Bob
US
Jack
UK
John
UK
Required Output (.csv) I can’t display the below as a table in this post but obviously I need two columns of data
Here is another way for doing batching in Linq without MoreLinq (or writing own extension method)
Not very effective either but more scalable
If you aren’t familiar with Linq, probably better approach would be return to basics: write some simple loop on array of strings and carefully deal with tail of your sequence.