Exemplo n.º 1
0
 def __init__(self, file, from_pickle=False):
     if from_pickle:
         data = pickle.load(file)
         Checker.clean_global_init(data["checker_meta"])
         Seat.counters = data["seats_meta"]
         self.__dict__.update(data["controller"].__dict__)
         return
     self.email_handle = list()
     self.mode = {"people": "None"}
     self.last_change = None
     self.people = pd.DataFrame()
     self.auds = dict()
     self.inds = list()
     self.teams = list()
     self.seed = 1
     found_main_settings = False
     excel_file = ExcelFile(file)
     for name in excel_file.sheet_names:
         raw_frame = excel_file.parse(name, index_col=None, header=None)
         unresolved_dict = splitter(raw_frame, named=True)
         if "main_settings" in unresolved_dict.keys():
             if found_main_settings:
                 raise ControllerException("Две страницы с общими настройками!")
             found_main_settings = True
             Checker.raw_global_init(unresolved_dict)
             self.checker = Checker()
     if not found_main_settings:
         raise TypeError("Настройки не найдены, на странице с настройками нужен ключ main_settings")
     for name in excel_file.sheet_names:
         raw_frame = excel_file.parse(name, index_col=None, header=None)
         unresolved_dict = splitter(raw_frame, named=True)
         if "main_settings" not in unresolved_dict.keys():
             tmp = Auditory(unresolved_dict, outer_name=name)
             if tmp.inner_name in self.auds.keys():
                 del tmp
                 raise TypeError("Есть одинаковые аудитории")
             else:
                 self.auds[tmp.inner_name] = tmp
     self._message_upd()
Exemplo n.º 2
0
 def load_auditory(self, file):
     """
     Повторяющиеся загружены не будут
     :param file:
     :return:
     """
     excel_file = ExcelFile(file)
     for name in excel_file.sheet_names:
         raw_frame = excel_file.parse(name, index_col=None, header=None)
         unresolved_dict = splitter(raw_frame, named=True)
         if "settings" in unresolved_dict.keys():
             tmp = Auditory(unresolved_dict, outer_name=name)
             if tmp.inner_name in self.auds.keys():
                 del tmp
             else:
                 self.auds[tmp.inner_name] = tmp
Exemplo n.º 3
0
    else:
        return writer.My_excel_stream()


if __name__ == '__main__':
    description = "\
            This program allows you to parse excel documents and split multiple sequences to different tables or sheets. \
            It is also possible to name them depending on the mark of the table. You can choose stream in {std, \
            excel}. If you want single file output it is possible to stream output into it. \
            See more information below."

    parser = argparse.ArgumentParser(description=description)
    parser.add_argument("input", nargs='*', help="name of the file that you want to split should have .xlsx extension")
    parser.add_argument("-d", "--debug", action='store_true', default=False, help="this flag allows to make a log file")
    parser.add_argument("-n", "--named", action='store_true', default=False,
                        help="name every table, or excel sheet with a mark as top left side cell")
    parser.add_argument("-s", "--stream", default="std", choices=["std", "excel"],
                        help="where to store the results, std by default")
    parser.add_argument("-f", "--file", help="if you want to store all results in one excel book? name it")
    opts = vars(parser.parse_args(sys.argv[1:]))
    if (not opts["input"]) or (not opts["input"][0].endswith(".xlsx")):
        print("INPUT name of the file that you want to split should have .xlsx extension")
        parser.print_usage()
        sys.exit(1)
    # Init stream
    stream = init_stream(opts["stream"], opts["file"])
    table = pd.read_excel(opts["input"][0], header=None)
    result_dict = reader.splitter(table, named=opts["named"], debug=opts["debug"])
    stream.write(result_dict)
    stream.close()