Question: lines of numbers separated with empty lines 
Author Message
 Question: lines of numbers separated with empty lines

Hi there,

I have the following problem:

I have lines with numbers; every several lines, the numbers are
separated with 2 empty lines. How can I count the # of lines
with numbers between 2 separations?

For example

1 2
2 3             4 lines here
3 4
4 5

1 2              2 lines here
5 6

2 3
3 4              3 lines here
4 5

Thank you!

/PS



Thu, 07 Jun 2007 01:04:36 GMT  
 Question: lines of numbers separated with empty lines
The following program counts the number of non-blank lines between
blank lines. You could modify it to check that non-blank lines contain
two integers. Google Groups seems to mess up the indentation.

program xread
implicit none
integer                      :: ierr,nnum
integer, parameter           :: in_unit=20
character (len=100)          :: text
character (len=*), parameter :: in_file="read_test.dat"
open (unit=in_unit,file=in_file,action="read",status="old")
nnum = 0
do
read (in_unit,"(a)",iostat=ierr) text
if (ierr /= 0) then
print*,nnum
exit
end if
if (text == "") then
if (nnum > 0) print*,nnum
nnum = 0
else
nnum = nnum + 1
end if
end do
end program xread

output:
4
2
3



Thu, 07 Jun 2007 01:58:30 GMT  
 Question: lines of numbers separated with empty lines
Thanks - it works fine!


Thu, 07 Jun 2007 08:39:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. text widget, how to get line number of first line displayed

2. new question in how can i read data from file line by line

3. Capture stdout/stderr line by line from an exec question

4. NetExpress Question about Line Numbers

5. Reading unknown number of lines in unknown number of files

6. Delete empty lines

7. Matching empty lines in a textfile?

8. Empty lines in the Body of a mail

9. Find empty lines in array

10. one liner? --- split file at empty line

11. Empty line after writing to file

12. Removing empty lines

 

 
Powered by phpBB® Forum Software