Page 1 of 1
Need to reset the count to zero in batch after each address
Posted: 09 Dec 2009 14:00
by Ken
How do I reset the variable %%a back to zero after it adds, so when it reaches the next line and the find variable %%a it will give a correct count.
When it finds the first address I want it to execute two more finds to give me a total for Request -DCC and Clean Request -DCC for that location, then drop down to another address and do two more finds giving a new count for Request -DCC and Clean Request -DCC.
Code:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
type "MultiProperties06-09.txt" | find " 9850 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
for /f "tokens=2 delims=:" %%a in ('find.exe /C "Clean Request - DCC" "MultiProperties06-09.txt"') do (echo Location has%%a Clean Request - DCC>>"Updated Properties.xls" )
Thank you for your help
Ken
Posted: 10 Dec 2009 12:42
by avery_larry
%%a is never 0, and it doesn't need to be reset -- it's only defined inside the for loop and it's value is determined uniquely each time it loops through the for command. It's not some type of value that increments or does addition.
Posted: 10 Dec 2009 16:34
by Ken
Thank you for explaining. I guess I need to reset the value of "Request -DCC" and "Clean Request -DCC" to zero but I haven't figured out how. I want it to count then reset to zero before reading the next address and so forth then continue until the end of file.
Thanks Ken
Posted: 11 Dec 2009 15:16
by avery_larry
In the code you have above, there is nothing that's counting -- other than the FIND statement. I'm completely not understanding what isn't working.
I want it to reset the count after each address
Posted: 14 Dec 2009 21:11
by Ken
avery_larry,
I want it to reset the count after each address, right now it counts all the Request - DCC and Clean Request - DCC in the entire file.
Example of current output:
Request - DCC = 1205 (for every location)
Clean Request - DCC = 1487 (for every location)
If it is reset to zero after each location I will get a correct total.
Example if I have a location at 8550 N CENTRAL ACRD that have the following (2 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 2
Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address 9850 N CENTRAL ACRD that have the following (6 Request - DCC) and (5 Clean Request - DCC)
I would like it to total the following: Request - DCC = 6
Clean Request = DCC = 5
Total count for Location = 11
Thank you for looking at the code
Ken
Posted: 16 Dec 2009 10:56
by avery_larry
So you have 1 big file, and then individual portions of the file you want treated separately?
That's a lot of work. You have to go line by line through it, keeping track of what part of the file you're in, and establish multiple variables that increment when you find the string, and finally put it all together after you've gone through the entire file.
Posted: 16 Dec 2009 11:51
by Ken
avery_larry
Thats correct... I am just having a problem with the totals after each address... It totals the entire file insead of each address. Do you have any suggestions?
Thanks for your help
Ken
Posted: 16 Dec 2009 15:07
by Ken
avery_larry
Do you have a sample of code I might try to reset counts in a file?
Thanks for your help
Ken
Posted: 18 Dec 2009 15:31
by avery_larry
Well, let's start with getting a sample of your input file . . .
Posted: 18 Dec 2009 19:55
by Ken
avery_larry
Thank you for you help... This is the type of data I am looking at when running my batch file although there is many more addresses.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161944 Clean Request - DCC 9850 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
Thanks
Ken
Posted: 21 Dec 2009 14:03
by Ken
avery_larry wrote:Well, let's start with getting a sample of your input file . . .
avery_larry
Do you have any suggestions, example or sample code that I might use to attain the results I am looking for. I posted a sample of data.
Any help would be great
Thank you
Ken
Posted: 22 Dec 2009 08:06
by avery_larry
If EVERY LINE has the address you're interested in, then you can use a double find command:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
So the find /c command which actually does the counting will only have the results of the find "property" command.
Posted: 23 Dec 2009 08:53
by Ken
avery_larry
Thank you for the code but it is still not giving me what I need.
With your code and a second find added for "Clean Request - DCC"
This is what the output looks like.
09-00161921 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161928 Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161960 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161965 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161972 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161986 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
09-00161994 Clean Request - DCC 8550 N CENTRAL ACRD 54-M-Mapsco Page-Zone 005000-Census Tract
I am trying to get it with the totals at the bottom after each address.
Location has Request - DCC = 2
Location has Clean Request = DCC = 5
Total count for Location = 7
Then when it reads the next address it will show a new count.
Code Used:
type "MultiProperties06-09.txt" | find " 8550 N CENTRAL ACRD " >> "Updated Properties.xls"
for /f "tokens=2 delims=:" %%a in ('find " 8550 N CENTRAL ACRD " "MultiProperties06-09.txt"| find /C "Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
find /C "Clean Request - DCC" ') do (echo Location has%%a Request - DCC>>"Updated Properties.xls" )
Thank you for all your help
Ken
Posted: 23 Dec 2009 12:09
by avery_larry
It should be as simple as changing the address in both of the find statements and it should give you the correct count.
Post your entire code if you're continuing to have problems.