Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: TXTs to XLS or TXT Merge  (Read 4018 times)

0 Members and 1 Guest are viewing this topic.

poenie

  • Guest
TXTs to XLS or TXT Merge
« on: August 17, 2007, 11:00:52 PM »
I'm tring to merge 4 txt files to 1 file (either a xls or txt) Its easy to do, but the output file list the files contents under each other.  Is there dos code where by these files can be listed next to each other, eg xls into coloms and/or txt tab deliminated.

eg.

1.txt = 1,2,3                   >>>>  Output file           1      A
2.txt = A,B,C                                                          2     B
                                                                              3     C

Poenie

DeltaSlaya



    Apprentice
  • Google
    Re: TXTs to XLS or TXT Merge
    « Reply #1 on: August 18, 2007, 05:24:23 AM »
    Yea I'll try do something in batch, it might take a while...
    System specs:
    Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
    ASUS Striker Extreme
    XFX 8600GT XXX Edition
    2x 1gB Corsair XMS2 DDR2-800
    Seagate Barracuda 320gB SATA
    Raidmax Ninja 918 (520W ATXV2.0 PSU)
    -

    DeltaSlaya



      Apprentice
    • Google
      Re: TXTs to XLS or TXT Merge
      « Reply #2 on: August 18, 2007, 05:27:20 AM »
      Ok I'll do one where the input files are delimited by ","s and I think the input files are going to have to be the same length.

      One question, WTH is this going to be used for, I can't see any use except homework?
      System specs:
      Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
      ASUS Striker Extreme
      XFX 8600GT XXX Edition
      2x 1gB Corsair XMS2 DDR2-800
      Seagate Barracuda 320gB SATA
      Raidmax Ninja 918 (520W ATXV2.0 PSU)
      -

      ghostdog74



        Specialist

        Thanked: 27
        Re: TXTs to XLS or TXT Merge
        « Reply #3 on: August 18, 2007, 07:03:36 AM »
        warning: not tested with different data formats. Only test with supplied example input files.
        Code: [Select]
        Option Explicit
        Dim objFSO,myFile1,myFile2,myLine,strF1,strF2
        Dim objF1, objF2,array1,array2,bigArray1(),bigArray2(),i,j
        Set objFSO=CreateObject("Scripting.FileSystemObject")
        myFile1 = "C:\temp\1.txt"
        myFile2 = "C:\temp\2.txt"
        Set objF1=objFSO.OpenTextFile(myFile1,1)
        i=0
        Do Until objF1.AtEndOfLine
        array1=Split(objF1.ReadLine,",")
        ReDim Preserve bigArray1(i)
        bigArray1(i) = array1
        i=i+1
        Loop
        i=0
        Set objF2=objFSO.OpenTextFile(myFile2,1)
        Do Until objF2.AtEndOfLine
        array2=Split(objF2.ReadLine,",")
        ReDim Preserve bigArray2(i)
        bigArray2(i) = array2
        i=i+1
        Loop
        For j=LBound(bigArray1) To UBound(bigArray1)
            For i=LBound(array1) To UBound(array1)
        WScript.Echo bigArray1(j)(i),bigArray2(j)(i)
        Next
        Next
        set objF1=Nothing
        set objF2=Nothing
        set objFSO=Nothing

        output:
        Code: [Select]
        C:\temp>more 1.txt
        1,2,3
        4,5,6

        C:\temp>more 2.txt
        A,B,c
        D,E,F

        C:\temp>cd \vbscript

        C:\vbscript>cscript /nologo test.vbs
        1 A
        2 B
        3 c
        4 D
        5 E
        6 F

        C:\vbscript>

        DeltaSlaya



          Apprentice
        • Google
          Re: TXTs to XLS or TXT Merge
          « Reply #4 on: August 18, 2007, 03:33:50 PM »
          Yea I wasn't able to figure out how to make this in Batch without being a max of 26 or having a bunch of variables.
          System specs:
          Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
          ASUS Striker Extreme
          XFX 8600GT XXX Edition
          2x 1gB Corsair XMS2 DDR2-800
          Seagate Barracuda 320gB SATA
          Raidmax Ninja 918 (520W ATXV2.0 PSU)
          -

          ghostdog74



            Specialist

            Thanked: 27
            Re: TXTs to XLS or TXT Merge
            « Reply #5 on: August 18, 2007, 06:01:46 PM »
            Yea I wasn't able to figure out how to make this in Batch without being a max of 26 or having a bunch of variables.
            why use batch? there are many other excellent program languages around that fills in what batch lacks.

            DeltaSlaya



              Apprentice
            • Google
              Re: TXTs to XLS or TXT Merge
              « Reply #6 on: August 18, 2007, 06:06:11 PM »
              I know.. The OP asked for batch so..

              I know C# but I don't think you can use it for stuff like this..
              System specs:
              Intel Core 2 Duo E6600 (up to 3.3 stock V and air)
              ASUS Striker Extreme
              XFX 8600GT XXX Edition
              2x 1gB Corsair XMS2 DDR2-800
              Seagate Barracuda 320gB SATA
              Raidmax Ninja 918 (520W ATXV2.0 PSU)
              -

              ghostdog74



                Specialist

                Thanked: 27
                Re: TXTs to XLS or TXT Merge
                « Reply #7 on: August 18, 2007, 06:11:58 PM »
                I know.. The OP asked for batch so..

                I know C# but I don't think you can use it for stuff like this..
                i think that if you know and its easier to do, just post. This forum is for learning , isn't it.?:) even if OP cannot or don't know how to use C#.