WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: MW4 on October 08, 2019, 03:50:34 PM

Title: Count of text lines?
Post by: MW4 on October 08, 2019, 03:50:34 PM
Hello everyone!

I have a long text file which is kind of in this format which is repeated for each Serial Number:
### is a mix of numbers and Letters, Option Descriptions are usually many words of differing lengths.
I want to get a count of options (which the number of lines varies from 10-30)..basically a count of everything after Type to Allowance

What I have

Serial Number 123456
Model
Type
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
Allowance
Total Price
End of Record
Next records...(same format)


What I Want

Serial Number 123456
Model
Type
Total Options 6
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
### Option description $$$$
Allowance
Total Price
End of Record
Next records...(same format)

What is the quickest and most efficient method to accomplish the addition of that line count line into the text file where I want it?


Title: Re: Count of text lines?
Post by: stanl on October 09, 2019, 02:43:26 AM
Your final sentence was a little confusing; seems like you wanted to insert the count into the text file after counting the options. Either way, there are a couple of methods looping through the file. Personally I would parse the file into a tables.
Title: Re: Count of text lines?
Post by: kdmoyers on October 09, 2019, 06:03:48 AM
Yeah, I'm with Stan. loop to read the sections, loading various lines into tables. at end of each section, dump the tables to the output file.
$0.02
Kirby