Count of text lines?

Started by MW4, October 08, 2019, 03:50:34 PM

Previous topic - Next topic

MW4

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?



stanl

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.

kdmoyers

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
The mind is everything; What you think, you become.