Example #1
0
class BridgeODSReader:
    def __init__(self, odsfilepath):
        self.loadODS(odsfilepath)

    def loadODS(self, path):
        self.__ods = ODSReader(path, clonespannedcolumns=True)

    def getSheet(self, name):
        return self.__ods.getSheet(name)

    def getSheetNames(self):
        return self.__ods.SHEETS.keys()

    def hasSheet(self, name):
        return name in self.__ods.SHEETS.keys()

    def getCell(self, sheet, row, col):
        return self.__ods.getSheet(sheet)[row][col]

    def getRow(self, sheet, row):
        return self.__ods.getSheet(sheet)[row]

    def getCol(self, sheet, col):
        cl = []
        for row in self.__ods.getSheet(sheet):
            cl.append(row[int(col)])
        return cl
Example #2
0
def odsSplit(srcods, sheetlist, newods):
    odsr = ODSReader(srcods)
    newods = createOds(newods)
    for item in sheetlist:
        s = createSheet(newods, item)
        rows = odsr.getSheet(item)
        for elem in rows:
            odsWrite(s, elem)
    odsClose(newods)
Example #3
0
def multiOdsSplit(srclist, sheetlist, newods):
    newods = createOds(newods)
    for arch in srclist:
        odsr = ODSReader(arch)
        for item in sheetlist:
            if odsr.hasSheet(item):
                s = createSheet(newods, item)
                rows = odsr.getSheet(item)
                for elem in rows:
                    odsWrite(s, elem)
    odsClose(newods)
Example #4
0
 def ods(self,archivo):
     my_file = open(str(archivo),'rb')
     doc = ODSReader(my_file, clonespannedcolumns=True)
     table = ''
     try:
         table = doc.getSheet(u'Sheet1')
     except:
         table = doc.getSheet(u'Hoja1')
     my_dict = {}
     for i in range(len(table)):
         for j in range(len(table[i])):
             if(i==0):
                 my_dict[table[i][j]] = []
             else:
                 my_dict[table[0][j]].append(table[i][j])
     print my_dict
     return my_dict
Example #5
0
    def __init__(self, inputfile):
        self.conceitos = {}
        self.faltas = {}
        self.aulas = {}

        spreadsheetdoc = ODSReader(inputfile)
        sheetConceitos = getSheetConceitos(spreadsheetdoc)
        sheetPresencas = getSheetPresencas(spreadsheetdoc)
        sheetPlanoDeAulas = getSheetPlanoDeAulas(spreadsheetdoc)
        associateSheets(conceitos=sheetConceitos,
                        presencas=sheetPresencas,
                        plano=sheetPlanoDeAulas)

        self.conceitos, self.faltas = getConceitosFaltas(sheetConceitos)

        if sheetPresencas.planoDeAulas is not None:
            iterSheet = iter(sheetPresencas.planoDeAulas.iteritems())
            for data, aula in iterSheet:
                self.aulas[strDateCanonicalize(data)] = aula

        iterSheet = iter(sheetPresencas)
        next(iterSheet)
        rowNumber = 1
        for row in iterSheet:
            ++rowNumber
            ra = 0
            try:
                ra = int(row.get('ra', 0))
            except ValueError:
                pass
            if ra == 0:
                continue
            for data, idxData in sheetPresencas.idxData.iteritems():
                data = strDateCanonicalize(data)
                if data not in self.aulas:
                    self.aulas[data] = Aula(dia=data.strip('/')[0],
                                            mes=data.strip('/')[1],
                                            ano=sheetPlanoDeAulas.ano)
                presenca = str(row.get(idxData, '')).strip().lower()
                if presenca == 'p' or presenca == '1':
                    self.aulas[data].mapRAPresencas[ra] = True
                elif presenca == 'f' or presenca == '--' or \
                     presenca == '-' or presenca == '0':
                    self.aulas[data].mapRAPresencas[ra] = False
                else:
                    #print >> sys.stderr, \
                    #  "Presença não registrada para a data %s, ra %d" % (data,ra)
                    self.aulas[data].mapRAPresencas[ra] = None
Example #6
0
def main(argv):
    inputFilename = ''
    outputFilename = ''

    try:
        opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="])
    except getopt.GetoptError:
        print('File error: test.py -i <inputfile> -o <outputfile>')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print('test.py -i <inputfile> -o <outputfile>')
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputFilename = arg
        elif opt in ("-o", "--ofile"):
            outputFilename = arg

    if os.path.isfile(inputFilename):
        print('Found file:', inputFilename)
    else:
        print('Unable to find file:', inputFilename)
        sys.exit()

    # Open our output file...
    outputFile = open(outputFilename, 'w')
    print('Opened file: ', outputFilename)

    # Open input spreadsheet and grab sheet 1
    inputFile = ODSReader(inputFilename)
    sheet1 = inputFile.getSheet(u'Sheet1')
    print('Opened input file, starting build...')

    # Build output string
    outputFile.write(
        'using UnityEngine;\nusing System.Collections;\nusing System;\n\npublic static class LOC_Strings\n{\n\n\tpublic enum tLOC_Identifier\n\t{\n'
    )

    #    for i in range(len(sheet1)):
    #       for j in range(len(sheet1[i])):
    #            print (sheet1[i][j])

    for i in range(len(sheet1)):
        outputFile.write('\t\t_' + sheet1[i][0] + ' = ' + str(i) + ',\n')

    outputFile.write('\t};\n\n')

    print('English strings ...')
    outputFile.write('\tpublic static string[] LOC_EnglishStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][1] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][1] + '\"\n\t};\n')

    print('French Strings...')
    outputFile.write('\tpublic static string[] LOC_FrenchStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][2] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][2] + '\"\n\t};\n')

    print('German strings...')
    outputFile.write('\tpublic static string[] LOC_GermanStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][3] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][3] + '\"\n\t};\n')

    print('Spanish strings...')
    outputFile.write('\tpublic static string[] LOC_SpanishStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][4] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][4] + '\"\n\t};\n')

    print('Italian strings...')
    outputFile.write('\tpublic static string[] LOC_ItalianStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][5] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][5] + '\"\n\t};\n')

    print('Russian strings...')
    outputFile.write('\tpublic static string[] LOC_RussianStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][6] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][6] + '\"\n\t};\n')

    print('Brazilian strings')
    outputFile.write('\tpublic static string[] LOC_BrazilianStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][7] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][7] + '\"\n\t};\n')

    print('Japanese strings')
    outputFile.write('\tpublic static string[] LOC_JapaneseStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][8] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][8] + '\"\n\t};\n')

    print('Finnish strings...')
    outputFile.write('\tpublic static string[] LOC_FinnishStrings = {\n')

    for i in range(len(sheet1) - 1):
        outputFile.write('\t\t\"' + sheet1[i][9] + '\",\n')

    outputFile.write('\t\"' + sheet1[len(sheet1) - 1][9] + '\"\n\t};\n}')

    outputFile.close()
Example #7
0
 def loadODS(self, path):
     self.__ods = ODSReader(path, clonespannedcolumns=True)
def load_troupe_info(filename):
    from ODSReader import ODSReader
    doc = ODSReader(filename)
    troupeDatabase = doc.getSheet("avail")
    return troupeDatabase[1:]  # remove headers
Example #9
0
import helpers.camera as camera

import cv2
import logging

logging.basicConfig(level=logging.DEBUG)

colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
ax = plot_helper.prepare_plot()

# pictureNumbersMin = 76
# pictureNumbersMax = 98
# n = pictureNumbersMax - pictureNumbersMin + 1
workDir = 'c:\work\windpropeller'

doc = ODSReader(u'metadata-v1_manual.ods', clonespannedcolumns=True)
table = doc.getSheet(u'1-A-PressureSide')
print(table)

# swap images 2nd and 3rd
# a, b = 2, 3
# table[a][0], table[b][0] = table[b][0], table[a][0]

img_dictionary = {}
img_params = {'x_min': 999999, 'y_min': 999999, 'x_max': -999999, 'y_max': -999999}

for i in range(1, len(table)):
    fileName = table[i][0]
    print(fileName)
    matrix_str = table[i][1]
    matrix = np.matrix(matrix_str).reshape(-1, 4)
Example #10
0
    parser = argparse.ArgumentParser(description='ODS to Arduino pins converter.')
    parser.add_argument('-i', action='store', dest="input_file", metavar='input-odf-file', required=True, help='Input ODS file')
    parser.add_argument('-o', action='store', dest="output_file", metavar='generated-header-file', type=argparse.FileType('wt'), default='arduino_pins.h', help='Output C++ header file for arduino pins.')
    parser.add_argument('-s', action='store', dest="sheet_name", required=True, help='Name of Sheet in ODS to read pins definition from.')
    parser.add_argument('-m', action='store', dest="device", required=True, help='Name of microcontroler the header is generated (example: ATmega128).')


    ns = parser.parse_args()

    old = os.dup(1)
    os.close(1)
    sys.stdout = ns.output_file

    cpa = re.compile(r'ADC([0-9]+)')
    cpt = re.compile(r'TIMER([0-9]+[A|B|C])')
    doc = ODSReader(ns.input_file)
    table = doc.getSheet(ns.sheet_name)
    ports = {}
    spi = []
    analogin = {}
    timers = {}
    pwm = []
    pins = []
    for r in table[1:]:
        if r[0] == '---':
            break
        pin = {'number' : int(r[0]), 'port' : r[1][1]+r[1][2], 'function' : r[2], 'comment' : r[3]}
        if not ports.has_key(r[1][1]):
            ports[r[1][1]] = []
        ports[r[1][1]].append(pin)
        pins.append(pin)