[R-br] Problema ao ler arquivo UTF-16 com nulos

Daniel Marcelino dmsilva.br em gmail.com
Quinta Novembro 1 01:40:48 BRST 2012


Tenta baixar os dados e importar do computador. É quase 1 gb de texto. É
praticamente impossível não ter nenhum erro de codificação.
Eu fiz assim e deu certo de novo com o arquivo "20120930_Servidores.csv":

data1 <- read.delim(file.choose(),header=TRUE,sep="\t",  fill=TRUE,
fileEncoding = "UTF-16LE")


R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> data1 <- read.delim(file.choose(),header=TRUE,sep="\t",  fill=TRUE,
fileEncoding = "UTF-16LE")
> head(data1)
  ID_SERVIDOR_PORTAL                       NOME            CPF
1            1493044  AALINE SEVERIANO DA SILVA ***.592.871-**
2            1890528 AARAO CARLOS LUZ MACAMBIRA ***.017.623-**
3            1762984 AARAO CAVALCANTE DE AMORIM ***.292.777-**
4            1920165      AARAO DE ANDRADE LIMA ***.559.144-**
5            1611738  AARAO DIAMANTINO OLIVEIRA ***.056.281-**
6            1611738  AARAO DIAMANTINO OLIVEIRA ***.056.281-**
  MATRICULA              DESCRICAO_CARGO CLASSE_CARGO
1   019****
2   016**** BIBLIOTECARIO-DOCUMENTALISTA            E
3   009**** AGENTE DE SERV DE ENGENHARIA            S
4   003****             PROFESSOR 3 GRAU            V
5   000****
6   000****    ANALISTA DO BANCO CENTRAL            E
  REFERENCIA_CARGO PADRAO_CARGO NIVEL_CARGO SIGLA_FUNCAO NIVEL_FUNCAO
1               NA                       NA
2               NA                       NA
3               NA                       NA
4               NA                       NA
5               NA                       NA          FBC         FDT1
6               NA           IV          NA
                                FUNCAO CODIGO_ATIVIDADE
1
2
3
4
5 FUNCAO COMISSIONADA DO BANCO CENTRAL             FDT1
6
            ATIVIDADE OPCAO_FUNCAO_TOTAL
1
2
3
4
5 CHEFE DE SUBUNIDADE
6
                          UORG_LOTACAO COD_ORG_LOTACAO
1                                                   NA
2                                                   NA
3                                                   NA
4                                                   NA
5 DEPTO. CONTR. GEST. PLAN. SUPERVISAO           25201
6 DEPTO. CONTR. GEST. PLAN. SUPERVISAO           25201
              ORG_LOTACAO COD_ORGSUP_LOTACAO          ORGSUP_LOTACAO
1                                         NA
2                                         NA
3                                         NA
4                                         NA
5 BANCO CENTRAL DO BRASIL              25201 BANCO CENTRAL DO BRASIL
6 BANCO CENTRAL DO BRASIL              25201 BANCO CENTRAL DO BRASIL
                        UORG_EXERCICIO COD_ORG_EXERCICIO
1
2
3
4
5 DEPTO. CONTR. GEST. PLAN. SUPERVISAO             25201
6 DEPTO. CONTR. GEST. PLAN. SUPERVISAO             25201
            ORG_EXERCICIO COD_ORGSUP_EXERCICIO
1
2
3
4
5 BANCO CENTRAL DO BRASIL                25201
6 BANCO CENTRAL DO BRASIL                25201
         ORGSUP_EXERCICIO TIPO_VINCULO SITUACAO_VINCULO
1                                   NA
2                                   NA
3                                   NA
4                                   NA
5 BANCO CENTRAL DO BRASIL            1 ATIVO PERMANENTE
6 BANCO CENTRAL DO BRASIL            2 ATIVO PERMANENTE
  COD_GRUPO_AFASTAMENTO COD_AFASTAMENTO DATA_INICIO_AFASTAMENTO
1                                    NA
2                                    NA
3                                    NA
4                                    NA
5                                    NA           Não informada
6                                    NA           Não informada
  DATA_TERMINO_AFASTAMENTO       REGIME_JURIDICO JORNADA_DE_TRABALHO
1
2
3
4
5            Não informada REGIME JURIDICO UNICO   40 HORAS SEMANAIS
6            Não informada REGIME JURIDICO UNICO   40 HORAS SEMANAIS
  DATA_INGRESSO_CARGOFUNCAO DATA_NOMEACAO_CARGOFUNCAO
1                                                  NA
2                                                  NA
3                                                  NA
4                                                  NA
5                27/04/2012                        NA
6                05/01/1998                        NA
  DATA_INGRESSO_ORGAO DOCUMENTO_INGRESSO_SERVICOPUBLICO
1
2
3
4
5                                             000000000
6                                             000000000
  DATA_DIPLOMA_INGRESSO_SERVICOPUBLICO DIPLOMA_INGRESSO_CARGOFUNCAO
1                                                                NA
2                                                                NA
3                                                                NA
4                                                                NA
5                        Não informada                           NA
6                        Não informada                           NA
  DIPLOMA_INGRESSO_CARGOFUNCAO.1 DIPLOMA_INGRESSO_SERVICOPUBLICO
1
2
3
4
5
6


2012/10/31 Jakson Alves de Aquino <jalvesaq em gmail.com>

> 2012/10/31 Roberto de Pinho <robertodepinho em gmail.com>:
> > tbm sem sucesso:
> >
> > ata1 <- read.delim(url,header=TRUE,sep="\t",  fill=TRUE, fileEncoding =
> > "UTF-16", as.is=T)
> > ata1 <- read.delim(url,header=TRUE,sep="\t",  fill=TRUE, fileEncoding =
> > "UTF-16")
> > ata1 <- read.delim(url,header=TRUE,sep="\t",  fill=TRUE, fileEncoding =
> > "UTF-16LE", as.is=T)
> > ata1 <- read.delim(url,header=TRUE,sep="\t",  fill=TRUE, fileEncoding =
> > "UTF-16LE")
>
> Se estiver usando um sistema operacional que tenha o programa sed
> instalado (qualquer distribuição do Linux), uma tentativa pode ser
> "limpar" o arquivo, removendo os 0s:
>
> sed -e 's/\x00//g' teste.csv > teste2.csv
> sed -e 's/\xff\xfe//' teste2.csv > teste3.csv
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
> código mínimo reproduzível.
>



-- 
"Small steps toward a much better world"

\begin{signature}
Daniel Marcelino
Land Phone 1+514 343 6111 #3799
3200 Jean Brillant,  Office C5071
Montreal, QC; H3T 1N8
Canada
\end{signature}
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121031/fbe67ed9/attachment.html>


Mais detalhes sobre a lista de discussão R-br