c# - Reading from txt file to array/list<> -


i need read of .txt file , save data array/list. file looks this:

row11    row12    row13 row21    row22    row23 row31    row32    row33 

between strings not dots, commas ... spaces. possible doing this. have never it. has experience problem?

next insert data array/list<> mysql, not problem. thanks.

edit: need insert 3 columns mysql .txt file.

use string.split(char[], stringsplitoptions) first parameter specifies want split string using spaces , tabs, , second parameter specifies ignore empty entries (for cases there multiple spaces between entries)

use code:

var lines = system.io.file.readalllines(@"d:\test.txt"); var data = new list<list<string>>(); foreach (var line in lines) {     var split = line.split(new[]{' ', '\t'}, stringsplitoptions.removeemptyentries);     data.add(split.tolist()); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -