1.

Solve : In need of batch file to remove header row of text document?

Answer»

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! :-)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
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! Exactly what software is the query software? Do you have Microsoft Office? If so, which version?The query software if CleverPath Forest & Trees and I'm using Microsoft Office Professional Edition 2003.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. 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. Remove the space before the >>Oldun - You are a genius....Thanks so much for all your help!!!



Discussion

No Comment Found