dbTalk Databases Forums  

Re: How do I remove the last line (Trailer line) in a file.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Re: How do I remove the last line (Trailer line) in a file. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: How do I remove the last line (Trailer line) in a file. - 08-04-2004 , 02:24 PM






The easiest way and I have used this at a client is to call the UNIX utility
from the cmdline and have it generate another file for you to use - trailer.
Short of that I do not think Windows has an equivalent so you would need to
read the rows in (FSO) and write them back out to another file.

Not nice on a big file.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Narendra" <Narendra (AT) discussions (DOT) microsoft.com> wrote

Quote:
Every morning we receive .csv files from a vendor and we need to remove
the last line which gives information like how many records in the file etc.
What is the easiest way to do it. The last line will always be in the
following format - TRAILER,#of records
Quote:
In unix there is a command called grep that does similar things, what is
the equivalent of this in Windows or for that matter how to do it.

I need to bcp in this data into our database. Thanks in advance for the
help.




Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: How do I remove the last line (Trailer line) in a file. - 08-04-2004 , 03:48 PM






In message <1C10757E-D3FF-4E49-866A-DD6BADC80F3A (AT) microsoft (DOT) com>,
Narendra <Narendra (AT) discussions (DOT) microsoft.com> writes
Quote:
Every morning we receive .csv files from a vendor and we need to remove
the last line which gives information like how many records in the file
etc. What is the easiest way to do it. The last line will always be in
the following format - TRAILER,#of records

In unix there is a command called grep that does similar things, what
is the equivalent of this in Windows or for that matter how to do it.

I need to bcp in this data into our database. Thanks in advance for the help.
GNU do unix utilities that run on Windows
(http://www.gnu.org/software/grep/), but plenty of others out there as
well, just do a quick search.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.