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

Author Topic: In need of batch file to remove header row of text document  (Read 13150 times)

0 Members and 1 Guest are viewing this topic.

swinters

    Topic Starter


    Rookie

    In need of batch file to remove header row of text document
    « on: September 22, 2009, 11:40:24 AM »
    Hi - I'm trying to find a solution to removing a header row from a text file that is exported each morning from a query.  The query software will not allow me to export the text file without the header row and the program using the text file will not work if the header row is present.  If anyone can help it would be much appreciated.
    Thanks! :-)

    oldun

    • Guest
    Re: In need of batch file to remove header row of text document
    « Reply #1 on: September 22, 2009, 05:25:33 PM »
    If the header is NOT on line 1, change the value of skip=1 accordingly.
    Code: [Select]
    @echo off
    for /f "skip=1 tokens=*" %a in ('type queryOutput.txt') do echo %a >>queryOutputNoHeader.txt

    swinters

      Topic Starter


      Rookie

      Re: In need of batch file to remove header row of text document
      « Reply #2 on: September 23, 2009, 08:10:21 AM »
      This worked!  However has created a new issue.  The new file it created without the 1st record now has an additional space at the end of each record and I'm sure you know how finicky programs can be...this extra space is causing the AS400 program to fail.  Any ideas on why it gets created that way and how to keep it from happening?  Thank you so much for all your help!  ;D

      soybean



        Genius
      • The first soybean ever to learn the computer.
      • Thanked: 469
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 10
      Re: In need of batch file to remove header row of text document
      « Reply #3 on: September 23, 2009, 08:25:56 AM »
      Exactly what software is the query software?  Do you have Microsoft Office?  If so, which version?

      swinters

        Topic Starter


        Rookie

        Re: In need of batch file to remove header row of text document
        « Reply #4 on: September 23, 2009, 08:36:24 AM »
        The query software if CleverPath Forest & Trees and I'm using Microsoft Office Professional Edition 2003.

        soybean



          Genius
        • The first soybean ever to learn the computer.
        • Thanked: 469
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 10
        Re: In need of batch file to remove header row of text document
        « Reply #5 on: September 23, 2009, 08:51:19 AM »
        OK, here's a workaround suggestion.  Open the exported file in Microsoft Excel, delete the header row, and then save the file in the original format or another format that can be imported into the AS400 program.

        Edit: Alternatively, you might be able to import it into Mircosoft Access and then export a file with no header from Access.

        swinters

          Topic Starter


          Rookie

          Re: In need of batch file to remove header row of text document
          « Reply #6 on: September 23, 2009, 08:58:23 AM »
          Well the whole point of this is to automate.  This is a daily task...the work around I'm currently using is opening the text file and deleting the header row manually and saving.  The query runs at 1am and exports the text file.  If I can get the batch file that "oldun" suggested to stop adding the extra spaces at the end I can schedule it to run right after the export is done and then viola...I won't even have to touch it.

          oldun

          • Guest
          Re: In need of batch file to remove header row of text document
          « Reply #7 on: September 23, 2009, 08:45:59 PM »
          Remove the space before the >>

          swinters

            Topic Starter


            Rookie

            Re: In need of batch file to remove header row of text document
            « Reply #8 on: September 24, 2009, 10:36:10 AM »
            Oldun - You are a genius....Thanks so much for all your help!!!