c# - Converting Text Files -


i have text file containing these. load in created form.

5jb01141570j4450901            1000    1051    2000    01161501b10g610m0350m200  0000006 

to produce this.

106262,5,jb,2015-01-14,70j4450901            ,1000    ,1051    ,2000    ,2015-01-16,0,1,b10g610m0350m200  ,6,, ,0,1/14/2015 3:06:16 pm 

how can converted it?

the first column row counts , last column indicates datetime when generated..

this maybe crude way, try , adjust suit yours. idea.

using system;  namespace consoleapplication1 {     internal class program     {         private static string data1;         private static int[] idx = new int[12] { 0, 1, 3, 9, 31, 39, 47, 55, 61, 62, 63, 81 };          private static void main(string[] args)         {             string datainput = "5jb01141570j4450901            1000    1051    2000    01161501b10g610m0350m200  0000006";              console.writeline("result :");              (int = 0; < idx.length - 1; i++)             {                 int len = idx[i + 1] - idx[i];                  //format date                 if (i == 2 | == 7)                 {                     datetime dt = convert.todatetime(datainput.substring(idx[i], len).substring(0, 2) +                         "/" + datainput.substring(idx[i], len).substring(2, 2) +                         "/" + datainput.substring(idx[i], len).substring(4, 2));                     data1 = data1 + dt.toshortdatestring() + ",";                 }                 else {                     data1 = data1 + datainput.substring(idx[i], len) + ",";                 }             }              console.writeline(data1 + datetime.now);              console.readkey();         }     } } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -