Computing.Net > Forums > Programming > How to delete first for lines in a txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to delete first for lines in a txt file

Reply to Message Icon

Name: sbm
Date: October 21, 2009 at 02:35:29 Pacific
OS: Windows 2000
CPU/Ram: 532
Subcategory: Batch
Comment:

I have an sql which prompts user to enter datefrom and dateto. I then spool the result in a txt file, add a header then spool to a .csv file. However, the first 4 lines (containing the following:Enter value for datefrom: 01-OCT-2009
Enter value for dateto: 10-OCT-2009
old 13: AND A.created BETWEEN '&&DateFrom' and '&&DateTo'
new 13: AND A.created BETWEEN '01-OCT-2009' and '10-OCT-2009') is displayed in the .csv which distorts the report.
Please let me know how i can delete this lines before spooling in the .csv

Thanks.

Note: Subject is How to delete the first four lines in a text file.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 21, 2009 at 03:53:45 Pacific
Reply:

@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=* skip=4 delims= " %%a in (myfile) do (
>> newfile echo %%a
)


=====================================
Helping others achieve escape felicity

M2


0

Response Number 2
Name: IVO
Date: October 21, 2009 at 03:56:33 Pacific
Reply:

Create your .csv file then streap away the first four lines so

@echo off > "Your_File.new"
for /F "skip=4 delims=" %%j in ('type "Your_File.csv"') do echo.%%j>>  "Your_File.new"
del "Your_File.csv"
ren "Your_File.new" "Your_File.csv"


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: How to delete first for lines in a txt file

script that searches lines in a txt www.computing.net/answers/programming/script-that-searches-lines-in-a-txt/16283.html

count of lines in all .txt files www.computing.net/answers/programming/count-of-lines-in-all-txt-files/16721.html

Robocopy function in a batch file www.computing.net/answers/programming/robocopy-function-in-a-batch-file/13172.html