How to account for missing data when reading txt files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Randall Benson
    New Member
    • Dec 2010
    • 11

    How to account for missing data when reading txt files?

    080415 0850 2.77 70.00
    080415 0900 2.54 79.00
    080415 1720 5.01 291.00
    080415 1730 5.24 293.00

    This is a sample of the text file i'm reading. Col 0 = yymmdd, col 1 = time in hhmm, col 2 = wind speed, col 3 = wind direction.

    There can be a maximum of 6 10 minute values in Col 1. If there are zero values for any hourly period, I need to assign a -9999 integer value for that missing wind speed and direction. Missing data here goes from 0910 to 1710 as you can see above. Your ideas?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use a loop. The first line in the text file will establish the base line and each subsequent line should be +10. If not, use your -9999, increment by 10 and check again. Repeat until it matches, at which point you move to the next line.

    Comment

    • Randall Benson
      New Member
      • Dec 2010
      • 11

      #3
      Ok. Inside a for loop that is reading each line, how would you proceed - line by line - incrementing by 10?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Use a variable to track where you should be.
        If line 1 is 750, then my baseline is 750, so I set my variable to 750. Increment by 10 and you get 800, line 2 should 800. If not, then I use -9999. Increment by 10 again to 810. Check line 2 again. Repeat until line 2 equals what you variable says it should be.

        Comment

        Working...