def __click_list(self): select_item = self.__combo_box_select_screen_type.currentText() if select_item == no_data_value(): select_item = "" result = self.__client.service.get_screen_type_data(select_item) self.__data.data = json.loads(result) self.__label_source_variable.setText("DB") self.__update_table_view()
def read_and_print_data(file_path: str) -> None: data = pd.read_csv(file_path, sep=";", header=None) columns_names = columns_headers() columns_names.append("none") data.columns = columns_names data = data.drop(columns=["none"]) data = data.fillna(no_data_value()) with pd.option_context("display.max_rows", None, "display.max_columns", None): print(data)
def read_from_xml_to_json(self, file_path: str) -> Dict[str, Dict[str, str]]: tree = ET.parse(file_path) root = tree.getroot() translate_dict = translate_headers_xls_to_name() data_dict = {} for child in root: data_dict[str(child.attrib["id"])] = {} for x in child: if len(x) == 0: data_dict[str(child.attrib["id"])][translate_dict[str( x.tag)]] = x.text if not ( (x.text is None) or (x.text == "")) else no_data_value() else: for y in x: data_dict[str(child.attrib["id"])][translate_dict[str( x.tag + " " + y.tag)]] = y.text if not ( (y.text is None) or (y.text == "")) else no_data_value() return data_dict
def translate_data(self, data_dict): translate_dict = translate_headers_name_to_xls() new_dict = {} for idx, values in data_dict.items(): new_dict[idx] = {} for key, item in values.items(): xml_name = translate_dict[key] xml_name_list = xml_name.split() item_to_write = item if item != no_data_value() else None if not xml_name_list[0] in new_dict[idx]: new_dict[idx][xml_name_list[0]] = {} if len(xml_name_list) != 1: new_dict[idx][xml_name_list[0]][ xml_name_list[1]] = item_to_write else: new_dict[idx][xml_name_list[0]] = item_to_write self.__data_dict = new_dict
def get_unique_list_from_db(self, column_name: str) -> List[str]: sql_query = f"SELECT DISTINCT `{column_name}` FROM `{table_name()}`" db_reader = ReadDB(self.__columns_headers) db_reader.create_connection(self.__is_file(file_path_db())) contents = db_reader.select_from_db(sql_query) return [x[0] if x[0] != "" else no_data_value() for x in contents]
def __set_empty_cell(self, row_contents: List[str]) -> List[str]: return [x if x != no_data_value() else "" for x in row_contents]
def __fill_empty_cell(self, row_contents: List[str]) -> List[str]: return [x if x != "" else no_data_value() for x in row_contents]