Solved How to create a sample file that contains uniques values

August 6, 2012 at 07:12:12
Specs: Windows
I need to create a batch script that will look at a large data file and create a new sample file that has one of each possible marketing asset id.

Sample Data:
campaignid|marketingassetid|campaigntacticid
123abc|a123a|123450987
456abc|a123a|123456789
123fgh|a123b|123456799
222333|a123b|123556677
222444|a123c|123098755

Expected Output
campaignid|marketingassetid|campaigntacticid
123abc|a123a|123450987
123fgh|a123b|123456799
222444|a123c|123098755


See More: How to create a sample file that contains uniques values

Report •

#1
August 6, 2012 at 14:26:33
✔ Best Answer
http://www.computing.net/answers/pr...
(borrowing from M2go)

@echo off > newfile & setLocal enableDELAYedeXpansioN
for /f "tokens=1-3 delims=|" %%a in (myfile) do (
findstr /i "|%%b|"<newfile >nul || >>newfile echo %%a^|%%b^|%%c
)
goto :eof

output will be incorrect if the "b" data (field 2) appears in "a" or "c" fields.


Report •

#2
August 7, 2012 at 12:45:21
Thank you worked perfectly

Report •
Related Solutions


Ask Question