Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Basically my batch script has to do a line count of a file (.txt) and append the value of the result to the end of the following (in parameter file):
I have a parameter file with following contents:
Filename is manohar.prm
Contents are as follows:[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
$$DRM45_RowCount=581
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=100
$$Fac_Subcat_RowCount=149 that has to be updated with rowcounts of a file (Test.txt) at the end of the variables as shown - please help....

@echo off & setlocal > manohar.tmp for /F %%j in ('type "Test.txt" ^| find /C /V ""') do set rowcnt=%%j for /F "tokens=1-2 delims==" %%j in (manohar.prm) do ( if "%%j"=="$$Fac_Subcat_RowCount" ( echo.%%j=%rowcnt% ) else ( if "%%k"=="" (echo.%%j) else (echo.%%j=%%k) ) ) >> manohar.tmpThe updated file is manohar.tmp; if correct delete the original one and rename.

Thank You Very Much IVO.....
Its really helping me a lot.Well I have few more clarifications required:
a) The record count value is present in a file (rec_cnt.txt) that has a single line in it that contains TRAIL0101 000000000007.
In the above statement TRAIL0101 is repeated value and 000000000007 is the row count, for example the row count is 30 then the value changes to 000000000030.
b) We are suppose to fetch the row count value from rec_cnt.txt ignoring the zeroes and add this value to the parameter file ------->
Now in the parameter file we have many lines - thus we need to search for the line that has a specific phrase like "w_DDDMD_LNDG_IMS_NONRET_SALES" as shown below and then update the count fetched after the '=' sign of $$DRM45_RowCount:-
[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$DRM45_RowCount = value that is been fetched.The requirement is too much - but I need some help.....

@echo off & setlocal EnableDelayedExpansion> manohar.tmp set /P rowcnt=< rec_cnt.txt set rowcnt=%rowcnt:* =% for /L %%j in (0,1,80) do if not "!rowcnt:~%%j,1!"=="0" ( set rowcnt=!rowcnt:~%%j! goto :DONE ) :DONE for /F "tokens=1-2 delims==" %%j in (manohar.prm) do ( if "%%j"=="$$DRM45_RowCount" ( echo.%%j=%rowcnt% ) else ( if "%%k"=="" (echo.%%j) else (echo.%%j=%%k) ) ) >> manohar.tmp

IVO thanks a lot for your help.....
The code is working perfectly except for a small bug in it which i have explained below:The file that has the count details (rec_cnt.txt) contains: the information as shown below:
HEADER0101IMS HEALTHXpo Weekly NEW.PROD.RW9305D.WK0933.LINK019.SRCESUPP W2009080210120090831132102ssnyder@us.imshealth.com
TRAIL0101 000000001016 0000000000CKSUM000002819980261
The above text is in a single line in the rec_cnt.txt.Issue/Bug:
---------------
The manohar.prm file that has the following content:
[WCPIT_BIO_EDW.WF:w_DDDMD_LNDG_IMS_NONRET_SALES]
$$Cust_RowCount=72648
$$Sales_RowCount=5235998
$$OuletChangeLog_RowCount=931
$$DRM45_RowCount=HEALTHXpo Weekly NEW.PROD.RW9305D.WK0933.LINK019.SRCESUPP W2009080210120090831132102ssnyder@us.imshealth.com
$$Control_RowCount=4495
$$Outl_Subcat_RowCount=100
$$Fac_Subcat_RowCount=149
IN the above file content the text in bold is been fetched from the rec_cnt.txt file and been pasted after "$$DRM45_RowCount".
Instead the code has to fetch only the record count details which is part of the text TRAIL0101 000000000007 where 7 is the actual count - so ideally it should something be like this.........
$$DRM45_RowCount = 7Thanks again - I am sure I nearing to the requirement.

Hi IVO,
Would also like to know how to have the batch file executed from Informatica 8.6 to implement the same.
Thanks and regards
Manohar Rao

Are you sure the text the line count is catched from is contained in ONE line?
From your post and the behavior of my script it seems the lines are two, the first beginning with HEADER and the other with TRAILER.
What is Informatica 8.6? I'm italian but never heard such application ( by the way Informatica is the Italian word for Information Technology).

Thanks for your response IVO.....
Wonderful - you question is perfect but I apologies for providing you an incorrect information. As the HEADER file is in *.001 format I used Notepad to open it which pulled the contents in a single line. Where as when I open the same HEADER file using Wordpad it is in two lines as you said - the first beginning with HEADER and the other with TRAILER.Well the answer for the other question is:
Informatica is a data integration platform, some of the key characteristics of Informatica that stand out are the
1. ETL (Data Extraction, Transformation and Load) process components and the user interface
2. Metadata Management
3. Wider/Huge amount of data handling.
In addition to the above I have posted another requirement in the same forum:
http://www.computing.net/answers/wi...Please assist.

In the script in Post #3 replace
set /P rowcnt=< rec_cnt.txt set rowcnt=%rowcnt:* =%
with
for /F "tokens=2" %%j in (rec_cnt.txt) do set rowcnt=%%jAbout Informatica 8.6 I can't help as I do not have any exposure to that environment.
About your question regarding unzipping the .gz archives the script is quite easy to code but it depends on the tool used to unzip as there is a lot on the web either commercial or free and each one has different command line parameters.
Take the advice posted: these questions are better handled in the Programming Forum..

Fantastic - IVO
Not sure how to thank you.....?The code is perfect and is just listening to my words now.....
Will revert if I need any clarification.
Do you have any specific email address where I can communicate if I am not able to reach you through this forum?Thanks Again!
:-)

Hi IVO,
Thanks for your message, in addition to the above requirement there is a small additional task that has to be considered.
The for loop that we have used:
for /F "tokens=2" %%j in (Count.001.head) do set rowcnt=%%j
fetches the row count details from the file Count.001.head, but can we have it modified to search a part of the file name string and consider the file that ends with 0001.head.
For example:
The actual file that has the row count is something like:
NEW.PROD.RW92452.CLI561.WK0933.SUMCOMMA.001.head
The only part that remains unchanged in the above file name is 'SUMCOMMA', so my script has to look into a folder named 'SRC_FILES' that has SUMCOMMA word as a part of the filename with extension 001.headOoooof I am really wonder or cannot imagine to have to code such a requirement without your help....
:-)
Thanks and regards
Mano

for %%k in (*SUMCOMMA.001.head) do ( for /F "tokens=2" %%j in (%%k) do set rowcnt=%%j )Use the mail address I sent as this thread is dying.

![]() |
Crystal Report design wit...
|
Endless Beep if any mic i...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |