|
Posted by billious on 10/09/06 04:30
"billious" <billious_1954@hotmail.com> wrote in message
news:4529c1ac$0$28985$a82e2bb9@reader.athenanews.com...
>
> "batman" <uspensky@gmail.com> wrote in message
> news:1160363613.855662.104440@b28g2000cwb.googlegroups.com...
>>i have a text file that is like:
>>
>> date = OCT0606
>> asdf
>> sdaf
>> asdfasdgsdgh
>> asdfsdfasdg
>> START-OF-DATA
>> asdfasdfg
>> asdfgdfgsfg
>> sadfsdfgsa
>> asdfgsdfg
>> END-OF-DATA
>> asdfgalsdkdfklmlkm
>> asdfgasdfg
>>
>>
>>
>> i need to clear everything from this file except the data between the
>> START-OF-DATA and END-OF-DATA using a batcj file... elternitavly i am
>> open to suggestions of how to import using bulk insert in sql without
>> changing the file at all. data is pipe seperated but obvioulsy has
>> plenty of junk data in it. i have 2 similar files at about 30mb and
>> 60mb in size. thnks everyone
>>
>
> Since you are posting from XP, do you want an XP solution?
> alt.msdos.batch.nt deals with NT-series, and alt.msdos.batch with DOS and
> 9x.
>
> Meanwhile, since pipe is a special character in DOS, can you be a little
> more explicit about the contents of your file? How is
> START-OF-DATA/END-OF-DATA detected (does it involve the presence of a pipe
> or is it contained in one or more data-fields?) Does any line start with a
> semicolon? Is there any non-alphameric content other than the pipes?
NT4/2K/XP/2K3 (NT+ systems) are discussed in alt.msdos.batch.nt as the
techniques used differ markedly from DOS/9x methods.
For instance, given data like:
----- data begins -------
a|b|c
d|e|f
0|start|1
2|3|4
5|6|7
8|end|9
g|h|i
j|k|l
----- data ends -------
in a file "psd.txt" then the following will produce "psdout.txt"
----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]set yel=Y
[4]for /f %%i in (psd.txt) do call :process "%%i" &if !yel!==Y echo
%%i>>psdout.txt
[5]goto :eof
[6]
[7]:process
[8]if %yel%==L set yel=Y
[9]if %yel%==N for /f "tokens=2delims=|" %%j in (%1) do if /i %%j==end set
yel=L
[10]if %yel%==Y for /f "tokens=2delims=|" %%j in (%1) do if /i %%j==start
set yel=N
[11]goto :eof
------ batch ends --------
Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed
The label :eof is defined in NT+ to be end-of-file but MUST be expressed
as :eof
Without better knowledge of your file's content, refining this is a little
difficult.
Navigation:
[Reply to this message]
|