예제 #1
0
def smallest_value(reader: TextIO) -> int:
    """Read and process reader and return the smallest value after the
    time_series header.

    >>> infile = StringIO('Example\\n1\\n2\\n3\\n')
    >>> smallest_value(infile)
    1
    >>> infile = StringIO('Example\\n3\\n1\\n2\\n')
    >>> smallest_value(infile)
    1
    """

    line = time_series.skip_header(reader).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 reader:
        value = int(line.strip())

        # If we find a smaller value, remember it.
        if value < smallest:
            smallest = value

    return smallest
예제 #2
0
def smallest_value(reader: TextIO) -> int:
    """Read and process reader and return the smallest value after the
    time_series header.

    >>> infile = StringIO('Example\\n1\\n2\\n3\\n')
    >>> smallest_value(infile)
    1
    >>> infile = StringIO('Example\\n3\\n1\\n2\\n')
    >>> smallest_value(infile)
    1
    """

    line = time_series.skip_header(reader).strip()

    if line != '':
        smallest = int(line)

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

            if line != '-':
                value = int(line)
                if value < smallest:
                    smallest = value

        return smallest
예제 #3
0
def process_file(reader: TextIO) -> int:
    line = time_series.skip_header(reader)

    largest = find_largest(line)

    for line in reader:
        large = find_largest(line)
        if large > largest:
            largest = large
    return largest
예제 #4
0
def smallest_value(reader):
    """(file open for reading) -> NoneType
    Read and process reader and return the smallest value after the 
    time_series header.
    """
    line = time_series.skip_header(reader).strip()
    smallest = int(line)

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

        if value < smallest:
            smallest = value 
    return smallest
예제 #5
0
def process_file(reader):
    """(file open for reading) -> int

    Read and process reader, which must start with a time_series header.
    Return the largest value after the header. There may be multiple pieces
    of data on each line.
    """

    line = time_series.skip_header(reader).strip()
    largest = find_largest(line)

    for line in reader:
        large = find_largest(line)
        if large > largest:
            largest = large

    return largest
예제 #6
0
def smallest_value_skip(reader):
    """ (file open for reading) -> NoneType
    Read and process reader, which must start with a time_series header.
    Return the smallest value after the header.  Skip missing values, which
    are indicated with a hyphen.
    """

    line = time_series.skip_header(reader).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 reader:
        line = line.strip()
        if line != '-':
            value = int(line)
            smallest = min(smallest, value)

    return smallest
예제 #7
0
def process_file(reader: TextIO) -> int:
    """time_series 헤더로 시작하는 reader를 읽고 처리한다. 헤더 이후에 나오는 
    가장 큰 값을 반환한다. 각 줄마다 데이터가 여러 개일 수 있다. 

    >>> infile = StringIO('Example\\n 20. 3.\\n 100. 17. 15.\\n')
    >>> process_file(infile)
    100
    """

    line = time_series.skip_header(reader).strip()
    # 지금까지 가장 큰 값은 첫 번째 줄에 있는 데이터 중 가장 큰 값이다.
    largest = find_largest(line)

    # 나머지 줄을 확인해서 더 큰 값이 있는지 찾는다.
    for line in reader:
        large = find_largest(line)
        if large > largest:
            largest = large
    return largest
예제 #8
0
def process_file(reader):
    """ (file open for reading) -> int
	
    Read and process reader, which must start with a time_series header.
    Return the largest value after the header.  There may be multiple pieces
    of data on each line.
    """

    line = time_series.skip_header(reader).strip()
    # The largest value so far is the largest on this first line of data.
    largest = find_largest(line)

    # Check the rest of the lines for larger values.
    for line in reader:
        large = find_largest(line)
        if large > largest:
            largest = large
			
    return largest
예제 #9
0
def smallest_value_skip(reader):
    """ (file open for reading) -> int
    Read and process reader, which must start with a time_series header.
    Return the smallest value after the header.  Skip missing values, which
    are indicated with a hyphen.
    """

    line = time_series.skip_header(reader).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 reader:
        line = line.strip()
        if line != '-':
            value = int(line)
            smallest = min(smallest, value)

    return smallest
예제 #10
0
def process_file(reader: TextIO) -> int:
    """Read and process reader, which must start with a time_series header.
    Return the largest value after the header.  There may be multiple pieces
    of data on each line.

    >>> infile = StringIO('Example\\n 20. 3.\\n 100. 17. 15.\\n')
    >>> process_file(infile)
    100
    """

    line = time_series.skip_header(reader).strip()
    # The largest value so far is the largest on this first line of data.
    largest = find_largest(line)

    # Check the rest of the lines for larger values.
    for line in reader:
        large = find_largest(line)
        if large > largest:
            largest = large
    return largest
예제 #11
0
def smallest_value_skip(reader: TextIO) -> int:
    """Read and process reader, which must start with a time_series header.
    Return the smallest value after the header.Skip missing values, which are indicated with a hyphen.
    >>> infile = StringIO('Example\\n1\\n-\\n3\\n')
    >>> smallest_value(infile)
    1
    """

    line = time_series.skip_header(reader).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 reader:
        line = line.strip()
        if line != '-':
            value = int(line)
            smallest = min(smallest, value)

    return smallest
예제 #12
0
def smallest_value(reader):
    """(file open for reading) -> NoneType
    
    Read and process reader and return the smallest value after the 
    time_series header.
    """
    line = time_series.skip_header(reader).strip()
    
    # Now line contains the first value which is also the smallest value
    # found so far, because it is the only one it has read.
    smallest = line
    
    for line in reader:
        value = int(line.strip())
        
        # if we find the smallest value rember it
        if value < smallest:
            smallest = value
    
    return smallest
예제 #13
0
def smallest_value(reader):
    """ (file open for reading) -> NoneType

    Read and process reader and return the smallest value after the
    time_series header.
    """

    line = time_series.skip_header(reader).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 reader:
        value = int(line.strip())

        # If we find a smaller value, remember it.
        if value < smallest:
            smallest = value

    return smallest
예제 #14
0
def smallest_value(reader):
    """ (file open for reading) -> int

    Read and process reader and return the smallest value after the
    time_series header.
    """

    line = time_series.skip_header(reader).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 reader:
        value = int(line.strip())

        # If we find a smaller value, remember it.
        if value < smallest:
            smallest = value

    return smallest
예제 #15
0
def smallest_value_skip(reader: TextIO) -> int:
    """time_series 헤더로 시작하는 reader를 읽어서 처리한다.
    헤더 이후에 나오는 가장 작은 값을 반환한다. 
    하이픈으로 표시되는 누락 값은 건너뛴다.

    >>> infile = StringIO('Example\\n1\\n-\\n3\\n')
    >>> smallest_value_skip(infile)
    1
    """

    line = time_series.skip_header(reader).strip()
    # 이제 line에 첫 번째 데이터 값이 들어 있고, 
    # 유일하게 찾은 값이므로 이 값이 현재 가장 작은 값이다.
    smallest = int(line)

    for line in reader:
        line = line.strip()
        if line != '-':
            value = int(line)
            smallest = min(smallest, value)

    return smallest
예제 #16
0
def smallest_value(reader):
    """ (file open for reading) -> NoneType
    Read and process reader and return the smallest value after the
    time_series header.
    """
    
    line = time_series.skip_header(reader).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 reader:
        if line.isdigit() :
            value = int(line.strip())
            smallest = min(smallest, value)







    return smallest
예제 #17
0
def smallest_value(reader):
	""" (file open for reading) -> NoneType
	Read and process reader and return the smallest value after
	the time_series header
	"""

	line = time_series.skip_header(reader).strip()

	# now line contains the first data value; this is also the smallest value
	# found so far
	if line == '':
			smallest =0
			line = 0

	smallest = int(line)

	for line in reader:
		line = line.strip()
		if line == "-":
			continue
		value = int(line)
		smallest = min(smallest,value)

	return smallest
예제 #18
0
def smallest_value(reader):
    """ (file open for reading) -> NoneType
	Read and process reader and return the smallest value after
	the time_series header
	"""

    line = time_series.skip_header(reader).strip()

    # now line contains the first data value; this is also the smallest value
    # found so far
    if line == '':
        smallest = 0
        line = 0

    smallest = int(line)

    for line in reader:
        line = line.strip()
        if line == "-":
            continue
        value = int(line)
        smallest = min(smallest, value)

    return smallest
예제 #19
0
        print(smallest_value(input_file))
import read_smallest
import urllib
url = 'http://robjhyndman.com/tsdldata/ecology1/hopedale.dat'
webpage= urllib.urlopen(url)
webpage
for line in webpage:
    line = line.strip()
    line = line.decode('utf-8')
    print(line)
import urllib.request
import urllib2.request
import urllib
urllib.urlretrieve(url, filename= "hopedale2.txt')
urllib.urlretrieve(url, filename= "hopedale2.txt")
time_series.skip_header('hopedale2.txt')
import time_series
time_series.skip_header('hopedale2.txt')
time_series.skip_header('hopedale1.txt')
time_series.skip_header('hopedale.txt')
time_series.process_file('hopedale.txt')
%clear
with open('hopedale2.txt', 'r') as inuput_file
with open('hopedale2.txt', 'r') as input_file
with open('hopedale.txt', 'r') as input_file
import os
os.curdir
os.chdir(".')
os.chdir(".")
with open('hopedale.txt', 'r') as input_file
%clear