User Profile

Collapse

Profile Sidebar

Collapse
Randall Benson
Randall Benson
Last Activity: Feb 10 '11, 09:00 PM
Joined: Dec 15 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • bvdet,

    I'm interested to know how you would change your solution above since column 2 is in the form of hhmm and so after 1950 the output needs to be 2000 and so on. And, after 2350, the date needs to change to 061202. How would you adjust for this? Thanks much! RB
    See more | Go to post

    Leave a comment:


  • Hello,
    I'm trying to follow your (dwblas) code solution above but I need some comments along the way. Could you briefly comment each line please? Thanks, RB
    See more | Go to post

    Leave a comment:


  • Thanks for the feedback - I'll deal with the -9999's in the average calculations loop.
    See more | Go to post

    Leave a comment:


  • Here's more detail: Col 0 is date (mmddyy), Col 1 is time (hhmm), cols 2,3 are wind speeds. Col 1 time and Col 0 date may start at any time whenever sensor starts measuring data. Once I fill in missing dates, times and values (-9999), then I'll go back and make hourly averages of the 10minute data - but I know how to do that.
    061201 1910 4.88 5.01
    061201 1920 4.54 4.71
    061201 1930 4.58 5.20
    061201 2010 4.65 4.91
    See more | Go to post

    Leave a comment:


  • Randall Benson
    started a topic How to insert data where it's missing?

    How to insert data where it's missing?

    Hello,

    I am trying to insert -9999 for any missing 10 minute data in a text file I am reading.

    Data format sample is as follows in the input text file:

    061201 1910 4.88 5.01
    061201 1920 4.54 4.71
    061201 1930 4.58 5.20
    061201 2010 4.65 4.91

    Required output:

    061201 1910 4.88 5.01
    061201 1920 4.54 4.71
    061201...
    See more | Go to post

  • Ok. Inside a for loop that is reading each line, how would you proceed - line by line - incrementing by 10?
    See more | Go to post

    Leave a comment:


  • 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...
    See more | Go to post

  • Hi again. Would you be able to tell me what is "s" in your code:
    list_to_average = [float(s) for s in lineList[2:]]

    Thanks,
    Randall
    See more | Go to post

    Leave a comment:


  • hmmm...still getting an error and typed in exactly as you suggested.

    Traceback (most recent call last):
    File "<pyshell#522>" , line 3, in <module>
    average = sum(list_to_ave rage)/len(list_to_ave rage)
    TypeError: 'float' object is not callable

    Also, i need each column averaged or columns 2 thru 6 not just one average of all data in columns 2 thru 6. Could you insert comments? ...
    See more | Go to post

    Leave a comment:


  • I tried your solution and this is what i got:


    >>> fileObj = open('c:\TestCo lData.txt','r')
    >>> for line in fileObj:
    lineList = line.strip().sp lit()
    if lineList[1] in ['1200', '1300']:
    list_to_average = [float(s) for s in lineList[2:]]
    average = sum(list_to_ave rage)/len(list_to_ave rage)
    print average



    Traceback (most recent call last):...
    See more | Go to post

    Leave a comment:


  • Randall Benson
    started a topic How to average column data in txt files?

    How to average column data in txt files?

    80409 1110 16.77 19.2 216.5 -9.97 -13.48

    My data resembles the above. I'm trying to average all columns except the first two, which are date columns. I need to average when the values in column 1 (the 1110 value) equal to 1100 or 1200, 1300, etc). I need to write the averaged columns to an output file. Thanks. Code sample below.
    Code:
    >>> fileIN = open('c:\TestColData.txt','r')
    >>> line = fileIN.readlines()
    ...
    See more | Go to post
    Last edited by bvdet; Dec 16 '10, 12:19 AM. Reason: Add code tags
No activity results to display
Show More
Working...