Results 1 to 7 of 7

Thread: [RESOLVED] File read CSV format and write new file with one word in one line

Threaded View

  1. #1

    Thread Starter
    Lively Member darkbb's Avatar
    Join Date
    Jan 2016
    Posts
    93

    Resolved [RESOLVED] File read CSV format and write new file with one word in one line

    I bumped into another difficulty.. I read the file (like CSV format) and, trying to write it in a single line. [Tried using For Loop , but, as i use Test1 lines.length, the output file only shows upto the old length]
    for example :

    Test1.txt contains : My output ends up only with : Output file Testresult.txt should be :
    abc/wzed|
    adc/wssf/ssed|
    sdkf/effd/qefdc/efsfd|
    efds/dfsd|
    abc|
    wzed|

    adc|
    wssf|
    ssed|

    sdkf/effd/qefdc/efsfd|
    efds/dfsd|
    abc|
    wzed|
    adc|
    wssf|
    ssed|
    sdkf|
    effd|
    qefdc|
    efsfd|
    efds|
    dfsd|

    Following is the part of coding... Please help...
    and.. i know that i can replace everything with "/" or "|" but, this is the format i'm looking for... some character will be coming after "|"... So, it must contain split & "|" in the end...

    Code:
    lines = IO.File.ReadAllLines(TextBox1.Text)
    For icnt As Integer = 0 To lines.Length - 1
      Dim lncnt As Integer
      If lines(icnt).Contains("|") Then
        Dim strq As String() = lines(icnt).Split("|")
        If strq(0).Contains("/") Then
          Dim spl1 As String() = strq(0).Split("/")
          For jcnt As Integer = 0 To spl1.Length - 1
            Dim strtmp As String = spl1(jcnt) & "|" & strq(1)
            lncnt = icnt + jcnt
            Array.Resize(lines, lines.Length + 1)
            For counter = lines.Length - 2 To lncnt Step -1
              lines(counter + 1) = lines(counter)
            Next
            lines(lncnt) = strtmp
          Next
          lines(lncnt + 1) = ""
          icnt = lncnt
          lncnt = 0
        Else
        End If
      Else
      End If
     Next
     IO.File.WriteAllLines(TextBox2.Text, lines)
    *Textbox1 & textbox2 get the location of the file...
    Last edited by darkbb; Aug 27th, 2016 at 01:05 AM. Reason: forgot to add a detail..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width