Well i don't know how to start, so i'll give some info to see if someone can help me start or give me a push or anything.

I got a .txt file containing
Example:

1   SN_MOB_THIEF_NPC    도적  0   0   盗贼  0   0   Thief   0   0   0   0   0   0   0   
1   SN_MOB_CH_MANGNYANG 망량  0   0   稻草精 0   0   Mangyang    0   0   0   0   0   0   0   
1   SN_MOB_CH_BIGEYEGHOST_CLON  소안귀 0   0   大眼鬼 0   0   Small-eyed Ghost    0   0   0   0   0   0   0   
1   SN_MOB_CH_BIGEYEGHOST   대안귀 0   0   大眼魔 0   0   Big-eyed Ghost  0   0   0   0   0   0   0   
1   SN_MOB_CH_GYO_CLON  늙은 교    0   0   黄鼬妖 0   0   Old Weasel  0   0   0   0   0   0   0   
1   SN_MOB_CH_GYO   교   0   0   黄鼬怪 0   0   Weasel  0   0   0   0   0   0   0   

The space between everything its a "Tab" space.

I need help trying to make it look like

1   SN_MOB_THIEF_NPC    0   0   0   Thief   0   0   0   0   0   0   0   
1   SN_MOB_CH_MANGNYANG 0   0   0   Mangyang    0   0   0   0   0   0   0   
1   SN_MOB_CH_BIGEYEGHOST_CLON  0   0   0   Small-eyed Ghost    0   0   0   0   0   0   0   
1   SN_MOB_CH_BIGEYEGHOST   0   0   0   Big-eyed Ghost  0   0   0   0   0   0   0   
1   SN_MOB_CH_GYO_CLON  0   0   0   Old Weasel  0   0   0   0   0   0   0   
1   SN_MOB_CH_GYO   0   0   0   Weasel  0   0   0   0   0   0   0   

And the text files have at least 10,000 lines each, and fixing them manually it will take for ever.

It should be like this

1   SN_MOB_THIEF_NPC[COLOR="Green"] 0   0   0   [/COLOR]Thief

1 TAB TEXT_FROM_FILE Tab 0 Tab 0 Tab 0 Tab ENGLISH TXT

So any ideas?

Recommended Answers

All 7 Replies

Try something like this, where you read in the data one line at a time, parse the data based on tabs, and rewrite only the columns you want (skipping colum 3 and 6).

Imports System.IO
Module Module1
   Sub Main()
      Dim lst_strData As New List(Of String)
      Dim fileIn = New StreamReader("c:/science/DaniWeb/DW_407322_VB_CON/inText2.txt", True)
      Dim fileOut = New StreamWriter("c:/science/DaniWeb/DW_407322_VB_CON/outText2.txt")
      While Not (fileIn.EndOfStream)
         lst_strData = fileIn.ReadLine().Split(Chr(9)).ToList()
         fileOut.WriteLine( _
            lst_strData(0) + Chr(9) + lst_strData(1) + Chr(9) +
            lst_strData(3) + Chr(9) + lst_strData(4) + Chr(9) +
            lst_strData(6) + Chr(9) + lst_strData(7) + Chr(9) +
            lst_strData(8) + Chr(9) + lst_strData(9) + Chr(9) +
            lst_strData(10) + Chr(9) + lst_strData(11) + Chr(9) +
            lst_strData(12) + Chr(9) + lst_strData(13) + Chr(9) +
            lst_strData(14) + Chr(9) + lst_strData(15))
      End While
      fileOut.Close()
      fileIn.Close()
   End Sub

End Module

"'ToList' is not a member of 'System.Array'"

Sorry, put this at line 2:

Imports System.Linq;

OR you can take that off and leave it as an array, if you want.

Sir... You're... My Hero !! lol
Worked perfectly (so far) i'll be trying to make my application and i'll see if it works for everything i needed with the text files!!

Thank you :)

Umm, ok i was building the application now, and made everything just ready to put the code in, and try it.

But this text file give me error

"Index was out of range. Must be non-negative and less than the size of the collection."

How many elements are you getting back from the splits?
Do you have an extra blank line at the end of your file?

By thines01

I reopened the thread because i need also multi-line editing (A line that splits)
Example:

My name
is
LOL

this code helped me :)

Imports System.IO
Module Module1

   Sub Main()
      Dim strData As String
      Dim lst_strData As New List(Of String)
      Dim fileIn = New StreamReader("c:/science/DaniWeb/DW_407322_VB_CON/textdata_equip&skill.txt", True)
      Dim fileOut = New StreamWriter("c:/science/DaniWeb/DW_407322_VB_CON/outText2.txt")
      While Not (fileIn.EndOfStream)
         strData = fileIn.ReadLine()
         If (strData.StartsWith("//")) Then
            Continue While
         End If

         lst_strData = strData.Split(Chr(9)).ToList()

         While (16 > lst_strData.Count)
            strData = strData + fileIn.ReadLine()
            lst_strData = strData.Split(Chr(9)).ToList()
         End While

         fileOut.WriteLine( _
            lst_strData(0) + Chr(9) + lst_strData(1) + Chr(9) +
            lst_strData(3) + Chr(9) + lst_strData(4) + Chr(9) +
            lst_strData(6) + Chr(9) + lst_strData(7) + Chr(9) +
            lst_strData(8) + Chr(9) + lst_strData(9) + Chr(9) +
            lst_strData(10) + Chr(9) + lst_strData(11) + Chr(9) +
            lst_strData(12) + Chr(9) + lst_strData(13) + Chr(9) +
            lst_strData(14) + Chr(9) + lst_strData(15))
      End While
      fileOut.Close()
      fileIn.Close()
   End Sub

End Module

Thank you very much :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.