예제 #1
0
def HRM(filename, numberOfMinutes):
    """Oversees the processing of the input CSV file to output JSON file.

    :param filename: A string containing the file for processing.
    :returns: JSON file with the metrics dictionary
    """
    FORMAT = '%(asctime)s %(message)s'
    DATEFMT = '%Y-%m-%d %H:%M:%S'
    logging.basicConfig(filename="log.txt",
                        level=logging.DEBUG,
                        format=FORMAT,
                        datefmt=DATEFMT)
    logging.info('Started.')
    reader.validate(filename)
    reader.existFile(filename)
    rawData = reader.readFile(filename)
    while "interpolate" in rawData[0]:
        rawData = cleaner.cleanInterpolate(rawData, 0)
    while "interpolate" in rawData[1]:
        rawData = cleaner.cleanInterpolate(rawData, 1)
    almostData = analyzer.produceNumpy(rawData)
    data = cleaner.cleanClipper(almostData, numberOfMinutes)
    metrics = outputter.createDictionary(data)
    JSONname = outputter.createJSON(metrics, filename)
    logging.info('Finished.\n')
예제 #2
0
def test_readFile(mktestfile):
    """Test the function readFile from reader.py

    :returns: test passed if read data is as expected, test failed if otherwise
    """
    from reader import readFile
    assert readFile(mktestfile) == [[0.11, 0.22], [0.88, 0.99]]
예제 #3
0
def test(file):
    pathList = readFile(file)
    GraphSet.set_universe(pathList)
    cycles = GraphSet.cycles()
    sizeList = sorted([len(cycle) / 2 for cycle in cycles])

    sizeList.reverse()
    print(sizeList)
예제 #4
0
파일: GUI.py 프로젝트: petergla/CSE442
        finishpage(score, root)
    # if there is still some question left then recall the makelayout function that will display a new question
    elif len(questionlist) > 0:
        makelayout(score, root, questionlist)


# function for the final page layout
def finishpage(score, root):
    frame3 = Frame(width=100, height=100)  #make frame
    frame3.pack(expand=True)
    photo = (PhotoImage(file="codebusters.gif"))  #fetch file
    label = Label(image=photo)
    label.image = photo  # keep a reference!
    label.pack(expand=True)
    label1 = Label(frame3,
                   text="The Final Score Is " + str(score),
                   font="Helvetica 22 bold",
                   fg='green',
                   bg='black')  #final score
    label1.grid(columnspan=True, rowspan=True, padx=10, pady=5)
    can = Canvas(frame3, width=10, height=10)  #change picture size/canvas size
    #can.create_image(200,200,image=photo)
    can.grid()
    print "This is the final page"


# reads a textfile where the questions are written, returns a list of question objects
questionlist = readFile('example_questions.txt')
# pass the list of questions to a function that creates the frame
setuptakenquestionlist(questionlist)
예제 #5
0
파일: main.py 프로젝트: HugoBCuri/tpia-ep
import reader
import value

fileName = "TestesGrid/RandomGoalInitialState/navigation_1.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
value.run(states, initialState, goalState, 20)

fileName = "TestesGrid/RandomGoalInitialState/navigation_2.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
value.run(states, initialState, goalState, 40)

fileName = "TestesGrid/RandomGoalInitialState/navigation_3.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
value.run(states, initialState, goalState, 60)

fileName = "TestesGrid/RandomGoalInitialState/navigation_4.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
value.run(states, initialState, goalState, 80)

fileName = "TestesGrid/RandomGoalInitialState/navigation_5.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
value.run(states, initialState, goalState, 100)

fileName = "TestesGrid/RandomGoalInitialState/navigation_6.txt"
print("###### {} ######".format(fileName))
states, initialState, goalState = reader.readFile(fileName)
예제 #6
0
      'return' : retorno,
      'VER' : verif,
      '+t' : sumaDimensionada,
  }
  func = dict_Ind.get(cuadr.action, 'False')
  if func != 'False':
    position = func(cuadr, contProg)
    return position
  return contProg + 1


#!---------------------------------------------------
#! EJECUCION
#!---------------------------------------------------

reader.readFile()
#? Inicializa Memoria Global
globSize = dirFuncs[reader.programa].tam
mem.memGlob.append(mem.memoria(globSize[0], globSize[1], globSize[2], 0, 0, 0, 0))
memoriaGlob = mem.memGlob[-1]
#? Inicializa Primera Memoria Local, contexto : Main
mainSize = dirFuncs["Main"].tam
mem.memStack.append(mem.memoria(mainSize[0], mainSize[1], mainSize[2], mainSize[3], mainSize[4], mainSize[5], mainSize[6]))
memoriaMain = mem.memStack[-1]

while cuad[contProg].action != 'ENDProgram':
  contProg = indicador(cuad[contProg], contProg)

memoriaGlob.printMem()
memoriaMain.printMem()
print('\n')
예제 #7
0
import gc
#fileName = input('Your txt file: ')
#pattern = input('Your pattern: ')

gc.disable() 

fileName = 'book.txt'

#reader.readFile("Paragraphs/para0.txt")
#reader.readFile("Paragraphs/para1.txt") 
#reader.readFile("Paragraphs/para2.txt") 
#"of"
#pattern = reader.readFile("Paragraphs/para2.txt")
pattern = "his"
# Get content's file
s = reader.readFile(fileName)

#print("	==> Text :: %s" %s)
print("	==> Pattern :: %s" %pattern)
print("	==> Pattern Length :: %d" %len(pattern))

#Bruteforce Algorithm
Bruteforce.bruteForce(s, pattern)

#Sunday Algorithm
Sunday.sunday(s, pattern)

#KMP Algorithm
KMP.KMP(s, pattern)

#FSM Algorithm
예제 #8
0
    folders = ['Manager/', 'Accounts/', 'Audit/', 'Analyst/', 'Data_Science/']
    results = {
        1: 'Manager',
        2: 'Accounts',
        3: 'Audit',
        4: 'Analyst',
        5: 'Data Science'
    }
    dataroot = 'resumeLabeled/'
    resume = list()
    label = list()
    if not os.path.isfile('datasetLabeled.csv'):
        for i, folder in enumerate(folders):
            for file in os.listdir(dataroot + folder):
                try:
                    text = reader.readFile(dataroot + folder + file)
                    if text is not None:
                        resume.append(reader.readFile(dataroot + folder +
                                                      file))
                        label.append(i + 1)
                except:
                    pass

        data = pd.DataFrame({'Resume': resume, 'category': label})
        data.to_csv('datasetLabeled.csv', sep=',')
    if not os.path.isfile('datasetLabeledProcessed.csv'):
        df = pd.read_csv('datasetLabeled.csv', sep=',')
        df = df.dropna()
        # df.category = df.category.astype(int)
        print(df.head())
        df.Resume = df.Resume.apply(preprocess)
예제 #9
0
import time
import threading
import os

def sendEmail(list):
    print("SendEmail task assigned to thread: " + format(threading.current_thread().name))
    print("ID of process running task sendEmail: " + format(os.getpid()))
    t = time.process_time()
    for contact in list:
        time.sleep(0.5)

    endTime = time.process_time() - t

print("Execution started...")
startTime = time.process_time()
email_data = reader.readFile("info_file.csv")

num = int(input("Enter number of threads, you want to use: "))
flag = True
while (flag):
    if (len(email_data) % num == 0):
        flag = False
    else:
        num = int(input("Not applicable entry. Enter again: "))

pivot = int(len(email_data)/num) #pivot point that breaks the data into pieces for each thread
list_of_threads = []
for i in range(num+1):
    thread_worker = threading.Thread(target=sendEmail, args=(email_data[pivot*i:pivot*(i+1)],))
    list_of_threads.append(thread_worker)
예제 #10
0
        drone.C = bestJob.C
        drone.nextAvailableTime += jobTime + 1
        drone.weight = 0
      
  print "Finished time with {}/{} remaining jobs".format(len(allJobs), totalJobs)
          
  return commands

  # find closest warehouse with item 0
  # then build the list of items this warehouse (still), this will be the last stop of the drone
  # go on to the next closest warehouse with the next missing item
  # stop when: either the order is fully satisfied, or the drone is completely loaded
  #   if order is satisfied, tell drone to take this trip (starting with the furthest warehouse)
  #   if drone is full: tell the drone to take this trip
  #                     take another drone to do the rest
  # 
  # for this order, we can compute the num drones needed and the duration (max time for all drones) 
  # we choose a start time when all drones are available
  # remember for each drone the time when they get available  

if __name__ == '__main__':
  filenames = ['busy_day', 'mother_of_all_warehouses', 'redundancy']
  for filename in filenames:
    rd = readFile(filename)

    commands =  secondAl(rd)
    with open(filename + '-result.txt', 'w') as f:
      f.write(str(len(commands)) + "\n")
      for com in commands:
        f.write(com.printCommand() + "\n")