Exemple #1
0
def process_file(r):
    '''Read and process reader r.'''

    line = skip_header(r).strip()

    # The largest value seen so far.
    largest = -1

    for value in line.split():

        # Remove the trailing period.
        v = int(value[:-1])
        # If we find a larger value, remember it.
        if v > largest:
            largest = v

    # Check the rest of the lines for larger values.
    for line in r:
        # The largest value seen so far.
        large = -1

        for value in line.split():

            # Remove the trailing period.
            v = int(value[:-1])
            # If we find a larger value, remember it.
            if v > large:
                large = v

        if large > largest:
            largest = large

    return largest
Exemple #2
0
def process_file(r):
    '''Read and process reader r.'''
    line = skip_header(r).strip()

    # The largest value so far.
    largest = find_largest(line)

    # Check the rest of the lines for larger values.
    for line in r:
        large = find_largest(line)
        if large > largest:
            largest = large

    return largest
def process_file(r):
    '''Read and process reader r.'''
    line = skip_header(r).strip()

    # The largest value so far.
    largest = find_largest(line)

    # Check the rest of the lines for larger values.
    for line in r:
        large = find_largest(line)
        if large > largest:
            largest = large

    return largest
def smallest_value(r):
    '''Read and process reader r to find the smallest value after the 
    TSDL header.'''
    line = tsdl.skip_header(r).strip()

    # Now line contains the first data value; this is also the smallest
    # value found so far, because it is the only one we have seen.
    smallest = int(line)
    for line in r:
        line = line.strip()
        value = int(line)

        # If we find a smaller value, remember it.
        if value < smallest:
            smallest = value
    return smallest
def smallest_value(r):
    '''Read and process reader r to find the smallest
    value after the TSDL header.'''
    line = tsdl.skip_header(r).strip()

    # Now line contains the first data value; this is also the
    # smallest value found so far, because it is the only one we have seen.
    smallest = int(line)
    for line in r:
        line = line.strip()
        value = int(line)

        # If we find a smaller value, remember it.
        if value < smallest:
            smallest = value
    return smallest
Exemple #6
0
def smallest_value(r):
  '''リーダーrを読み出し、TSDLヘッダのアとのデータから最小値を調べて返す'''

  line = tsdl.skip_header(r).strip()

  #line には最初のデータが含まれている。他に読んだデータがないので
  #このデータはそれまでに読み出した最小値でもある
  smallest = int(line)

  for line in r:
    line = line.strip()
    value = int(line)

    #新たな最小値が現れたら記録する
    if value < smallest:
      smallest = value

  return smallest
Exemple #7
0
def smallest_value_skip(r):
    '''Read and process reader r to find the smallest value after the TSDL
    header. Skip missing values, which are indicated with a hyphen.'''
    line = skip_header(r).strip()

    # Now line contains the first data value; this is also the smallest
    # value found so far.
    smallest = int(line)
    for line in r:
        line = line.strip()

        # Only process line if it has a valid value.
        if line != '-':
            value = int(line)

            # Process value; if we find a smaller value, remember if.
            if value < smallest:
                smallest = value

    return smallest
def smallest_value_skip(r):
    '''Read and process reader r to find the smallest value after the TSDL
    header. Skip missing values, which are indicated with a hyphen.'''
    line = skip_header(r).strip()
    
    # Now line contains the first data value; this is also the smallest
    # value found so far.
    smallest = int(line)
    for line in r:
        line = line.strip()
        
        # Only process line if it has a valid value.
        if line != '-':
            value = int(line)
            
            # Process value; if we find a smaller value, remember if.
            if value < smallest:
                smallest = value
                
    return smallest
Exemple #9
0
def smallest_value_skip(r,default=0):
  '''リーダーrを読み出し、TSDLヘッダの後のデータから最小値を調べて返します'''
  line = skip_header(r)
  if not line:
    return default

  #lineには最初のデータが含まれている。他に読んだデータがないので、
  #このデータはそれまでに読みだした最小値でもある
  smallest = int(line.strip())

  for line in r:
    line = line.strip()

    #有効な値が含まれているときに限り行を処理する
    if line != '-':
      value = int(line)

      #valueを処理、新たな最小値が現れたら記録する
      if value < smallest:
        smallest = value

  return smallest