Author Topic: Count of text lines?  (Read 66 times)

MW4

  • Full Member
  • ***
  • Posts: 173
Count of text lines?
« 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?



stanl

  • Pundit
  • *****
  • Posts: 948
Re: Count of text lines?
« Reply #1 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.

kdmoyers

  • Sr. Member
  • ****
  • Posts: 290
Re: Count of text lines?
« Reply #2 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
The mind is everything; What you think, you become.