By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

How to account for missing data when reading txt files?

P: 11
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?
Jan 6 '11 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,374
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.
Jan 6 '11 #2

P: 11
Ok. Inside a for loop that is reading each line, how would you proceed - line by line - incrementing by 10?
Jan 6 '11 #3

Rabbit
Expert Mod 10K+
P: 12,374
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.
Jan 6 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.