示例#1
0
def write_to_file(a_filename, asset_coll, prop_coll, cat_coll, dept_coll):
    wb = Workbook()

    asset_sheet = wb.add_sheet('Assets')
    write_assets(asset_sheet, asset_coll)

    prop_sheet = wb.add_sheet('Property Master')
    write_prop(prop_sheet, prop_coll)

    cat_sheet = wb.add_sheet('Category & Class')
    write_cat(cat_sheet, cat_coll)

    dept_sheet = wb.add_sheet('Department')
    write_dept(dept_sheet, dept_coll)

    wb.save(a_filename)
#!/usr/bin/env python
# Copyright (C) 2005 Kiseliov Roman

from xlwt3 import Workbook

w = Workbook()
ws = w.add_sheet('Hey, Dude')

ws.write(0, 0, 1)
ws.write(1, 0, 1.23)
ws.write(2, 0, 12345678)
ws.write(3, 0, 123456.78)

ws.write(0, 1, -1)
ws.write(1, 1, -1.23)
ws.write(2, 1, -12345678)
ws.write(3, 1, -123456.78)

ws.write(0, 2, -17867868678687.0)
ws.write(1, 2, -1.23e-5)
ws.write(2, 2, -12345678.90780980)
ws.write(3, 2, -123456.78)

w.save('numbers.xls')
示例#3
0
def SaveFinalResultsExcel(Results):
    currentRow = 0

    wb = Workbook()
    ws = wb.add_sheet('Testing Results')

    ws.write(0, 0, 'Files Tested')
    currentRow += 1

    ### Output the number of files ran per machine ###
    for file in Results._files:
        machine = file.replace("../Resources/", "")
        machine = machine.replace(".txt", "")
        ws.write(currentRow, 0, machine)
        ws.write(currentRow, 1,
                 str(Results._current_Output[file]['Numb Files']))
        currentRow += 1

    #### Output the any errors in the standard files ####
    currentRow += 1
    ws.write(currentRow, 0, 'Standard Files Errors')
    currentRow += 1
    for file in Results._files:
        machine = file.replace("../Resources/", "")
        machine = machine.replace(".txt", "")
        for key in Results._standard_Errors[file].keys():
            ws.write(currentRow, 0, machine + " - " + key)
            for col in range(len(Results._standard_Errors[file][key])):
                ws.write(currentRow, col + 1,
                         Results._standard_Errors[file][key][col])
            currentRow += 1

    #### Standard Files Missing ####
    currentRow += 1
    ws.write(currentRow, 0, 'Missing Standard Files')
    currentRow += 1

    for file in Results._files:
        machine = file.replace("../Resources/", "")
        machine = machine.replace(".txt", "")
        for key in Results._standard_Missing[file]:
            ws.write(currentRow, 0, machine)
            ws.write(currentRow, 1, key)
            currentRow += 1

    #### Output the Error terminations ####
    currentRow += 1
    ws.write(currentRow, 0, 'Error Terminations')
    currentRow += 1

    #Write the Machine names across the top
    currentCol = 1
    for file in Results._files:
        machine = file.replace("../Resources/", "")
        machine = machine.replace(".txt", "")
        ws.write(currentRow, currentCol, machine)
        currentCol += 1
    currentRow += 1

    #Loop through the files and output errors
    for file in Results._files:
        for key in Results._current_Errors.keys():
            ws.write(currentRow, 0, key)
            for col in range(len(Results._current_Errors[key])):
                ws.write(currentRow, col + 1,
                         Results._current_Errors[key][col])
            currentRow += 1

    #### Write out the Variations
    currentRow += 1
    ws.write(currentRow, 0, 'Variations')
    currentRow += 1
    ws.write(currentRow, 0, '- = Nothing Wrong')
    ws.write(currentRow, 2, 'M = Missing Standard')
    ws.write(currentRow, 4, 'R = Residual')
    ws.write(currentRow, 6, 'S = Steps')
    ws.write(currentRow, 8, 'U = Unknown Issue')
    currentRow += 1
    #Write the Machine names across the top
    currentCol = 1
    for file in Results._files:
        machine = file.replace("../Resources/", "")
        machine = machine.replace(".txt", "")
        ws.write(currentRow, currentCol, machine)
        currentCol += 1
    currentRow += 1

    for key in Results._variations.keys():
        ws.write(currentRow, 0, key)
        for col in range(len(Results._variations[key])):
            ws.write(currentRow, col + 2, Results._variations[key][col])
        currentRow += 1

    today = datetime.date.today()
    ExcelFile = '../Results/Results-' + str(today) + '.xls'
    wb.save(ExcelFile)
def processFIle(metfile,keywordfile,outputfile):      
    """ searches for keywords in filenames that are suspicious regarding pedo content"""
    regexp = re.compile("!|[]|]|;|\?|\(|\)|-|_|\.|\,")

    wb = open_workbook(metfile)
    
    book = Workbook()
    
    sheet1=book.add_sheet('Found')
    sheet2=book.add_sheet("NOT FOUND")
    
    s=wb.sheets()[0]
    sheet = wb.sheet_by_index(0)         #input sheet
    
    book = Workbook()
    
    sheet1=book.add_sheet('Found')
    sheet2=book.add_sheet("NOT FOUND",cell_overwrite_ok=True)
    
    
    
    #print ("number of roews",s.nrows)
    hashCalcprog=[]
    filesize=[]
    knowndotMedHashes=[]
    lastpostedUTC=[]
    lastsharedUTC=[]
    requestsAccepted=[]
    bytesUploaded=[]
    filenames=[]
    keywords=[]
    
    with open(keywordfile) as f: # Returns a file object
      keywords=[line.replace('\n','').encode('utf8') for line in f] # Invokes readline() method on file
  
        
    k=0
    sheet1.write(k,0,'Α/Α')
    sheet1.write(k,1,'keyword')   
   
    for col   in range(sheet.ncols):
      sheet1.write(k,col+2,sheet.cell_value(0,col) )
  

    for i in range(sheet.nrows):#read hashes of met xls file
        if i>1:
          Found=False
          knowndotMedHashes.append(sheet.cell_value(i,17))
          filename=str(sheet.cell_value(i,0)).encode('utf8')
          filenames.append(filename)
          filesize=sheet.cell_value(i,2)
          lastpostedUTC=sheet.cell_value(i,5)
          lastsharedUTC=sheet.cell_value(i,6) 
          requestsAccepted=sheet.cell_value(i,8)
          bytesUploaded=sheet.cell_value(i,9)
        
          for term in regexp.sub(' ',filename.decode()).split(' '):
             
             if term.encode('utf8').lower() in keywords:
                print ("FOUND",term.encode('utf8').lower(),term.encode('utf8').lower() in keywords,type(term.encode('utf8').lower()))
                k+=1
                sheet1.write(k,0,k)
                sheet1.write(k,1,term)
                for col   in range(sheet.ncols):
               
                  sheet1.write(k,col+2,sheet.cell_value(i,col) )
              
              
                Found=True 
                break
          if not Found:
             sheet2.write(i,0,i)
             for col   in range(sheet.ncols):
               
                  sheet2.write(i,col+1,sheet.cell_value(i,col) )
              
            
     
    book.save(outputfile)
示例#5
0
        result_file.write('follow:')
        tmp = list(network[i]['follow'])
        n=0
        s=''
        while n < len(tmp):
            s += str(tmp[n])
            s += ' '
            n += 1      
        result_file.write(s)
        result_file.write('\n')
        result_file.write('\n')
#print(visited)

from tempfile import TemporaryFile
from xlwt3 import Workbook
book = Workbook()
book.add_sheet('Node Graph')
book.add_sheet('Edge Graph')
edge_row = 0
for i in range(len(network)):
    sheet1 = book.get_sheet(0)
    for k in range(25):
        sheet1.col(k).width = 5000
        
    sheet1.write(i+1, 0, i+1)
    m = re.search(location, network[i]['info'])
    if m != None:
        loca = m.group(0)[3:-2].split(',')
        for j in range(len(loca)):
            sheet1.write(i+1, j+1, loca[j])