def convert(row_data): if len(row_data) == 1 and "elapsed" in row_data[0].lower(): return None row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() # TODO: fix data_nascimento (dd/mm/yyyy, dd/mm/yy, yyyymmdd, xx/xx/) # TODO: fix situacao # TODO: fix totalizacao new["cpf"] = fix_cpf(new["cpf"]) new["nome"] = fix_nome(new["nome"]) new["sigla_uf"] = fix_sigla_uf(new["sigla_uf"]) new["sigla_uf_nascimento"] = fix_sigla_uf( new["sigla_uf_nascimento"]) new["titulo_eleitoral"] = fix_titulo_eleitoral( new["titulo_eleitoral"]) new["codigo_cargo"], new["descricao_cargo"], new[ "pergunta"] = fix_cargo(new["codigo_cargo"], new["descricao_cargo"]) return new
def convert(row_data): if len(row_data) == 1 and "elapsed" in row_data[0].lower(): return None row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() # TODO: fix data_nascimento (dd/mm/yyyy, dd/mm/yy, yyyymmdd, xx/xx/) # TODO: fix situacao # TODO: fix totalizacao new["cpf"] = fix_cpf(new["cpf"]) new["nome"] = fix_nome(new["nome"]) new["sigla_unidade_federativa"] = fix_sigla_unidade_federativa( new["sigla_unidade_federativa"]) new["sigla_unidade_federativa_nascimento"] = fix_sigla_unidade_federativa( new["sigla_unidade_federativa_nascimento"]) new["titulo_eleitoral"] = fix_titulo_eleitoral( new["titulo_eleitoral"]) new["codigo_cargo"], new["cargo"], new["pergunta"] = fix_cargo( new["codigo_cargo"], new["cargo"]) new["candidatura_inserida_urna"] = SimNaoBooleanField.deserialize( new["candidatura_inserida_urna"]) new["data_eleicao"] = fix_data(new["data_eleicao"]) new["data_nascimento"] = fix_data(new["data_nascimento"]) if censor: row["cpf"] = obfuscate_cpf(row["cpf"]) row["email"] = "" return new
def convert_row(row): new = {} for new_name, old_name in field_map.items(): value = utils.unaccent(row[old_name]).upper() if new_name.startswith("data_"): value = str(utils.PtBrDateField.deserialize(value) or "") new[new_name] = value return new
def convert(row_data): row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() new["sigla_uf"] = fix_sigla_uf(new["sigla_uf"]) new["valor"] = fix_valor(new["valor"]) return new
def convert(row_data): row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() new["sigla_uf"] = fix_sigla_uf(new["sigla_uf"]) new["nome"] = fix_nome(new["nome"]) new["codigo_cargo"], new["descricao_cargo"], _ = fix_cargo( new["codigo_cargo"], new["descricao_cargo"]) return new
def convert(row_data): row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() new["ano"] = year # TODO: replace "2018-candidatos" with "2018" new["valor"] = fix_valor(new["valor"]) new["data"] = fix_data(new["data"]) new["data_prestacao_contas"] = fix_data(new["data_prestacao_contas"]) new["data_eleicao"] = fix_data(new["data_eleicao"]) new["cnpj"] = fix_cnpj_cpf(new["cnpj"]) new["cpf_cnpj_fornecedor"] = fix_cnpj_cpf(new["cpf_cnpj_fornecedor"]) return new
def _script_to_filename( self, format_string, options ): # Do format script replacing here. script_data = metadata.Metadata() script_data.copy( self.processed_data ) filename = script.ScriptParser().eval( format_string, script_data, self ) filename = filename.replace( "\x00", "" ).replace( "\t", "" ).replace( "\n", "" ) # replace incompatible characters if options["windows_compatible_filenames"] or sys.platform == "win32": filename = utils.replace_win32_incompat( filename ) if options["ascii_filenames"]: if isinstance( filename, unicode ): filename = utils.unaccent( filename ) filename = utils.replace_non_ascii( filename ) return filename
def convert(row_data): row = dict(zip(row_field_names, row_data)) new = {} for key in final_field_names: value = row.get(key, "").strip() if value in ("#NULO", "#NULO#", "#NE#"): value = "" new[key] = value = utils.unaccent(value).upper() new["sigla_unidade_federativa"] = fix_sigla_unidade_federativa(new["sigla_unidade_federativa"]) new["nome"] = fix_nome(new["nome"]) new["codigo_cargo"], new["cargo"], _ = fix_cargo( new["codigo_cargo"], new["cargo"] ) key = (new["codigo_situacao_candidatura"], new["situacao_candidatura"]) new["codigo_situacao_candidatura"] = self.codigo_situacao_candidatura[key] new["situacao_candidatura"] = self.situacao_candidatura[key] return new