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

Roberto de Pinho robertodepinho em gmail.com
Quarta Outubro 31 21:48:44 BRST 2012


O erro é somente no "20120930_Servidores.csv"

aqui no iMac:

url = "~/Downloads/teste.csv"   # que é o arquivo em "
http://doc-0c-9c-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/vpmci49343n9hbakrkf8spssbvdm5bf9/1351706400000/13580050277620078750/*/0B7_ApnYB_M44WnA4UHpOVDZKWjQ?e=download
"


x = read.delim(url,header=TRUE,sep="\t",  fill=TRUE)

Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string at '<ff><fe>I'




2012/10/31 Daniel Marcelino <dmsilva.br em gmail.com>

> Bom, eu tô usando um Macbook.
>
> Tente também UTF-8 e UTF-16LE. Aqui deu certo novamente com UTF-16LE.
>
> data1 <- read.delim(file.choose(),header=TRUE,sep="\t",  fill=TRUE,
> fileEncoding = "UTF-16LE")
>
> data1 <- read.delim(file.choose(),header=TRUE,sep="\t",  fill=TRUE,
> fileEncoding = "UTF-16LE")
>
> head(data1)
>
>    ANO MES ID_SERVIDOR_PORTAL            CPF
>
> 1 2012   5            1283851 ***.128.531-**
>
> 2 2012   5            1725850 ***.014.030-**
>
> 3 2012   5            2042804 ***.520.808-**
>
> 4 2012   5            1545949 ***.513.705-**
>
> 5 2012   5            1849695 ***.449.371-**
>
> 6 2012   5            1272960 ***.822.991-**
>
>                                          NOME
>
> 1   ABADIO MENDES FERREIRA
>
> 2 ABELARDO SCALCO ISQUIERDO
>
> 3   ADAIL DE ALMEIDA ROLLO
>
> 4    ADAILTON DOS SANTOS
>
> 5      ADALBERTO FAZZIO
>
> 6 ADALIA MARIA SILVA PONTES
>
>
>               OBSERVACAO
>
> 1 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
> 2 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
> 3 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
> 4 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
> 5 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
> 6 OS VALORES EXTRA-SIAPE NAO ESTAO CONSIDERADOS. ESTA INFORMACAO ESTARA
> DISPONIVEL ATE 30/AGO/2012
>
>
> 2012/10/31 Roberto de Pinho <robertodepinho em gmail.com>
>
>> Caro Daniel,
>>
>> obrigado, vou tentar amanhã.
>>
>> Acho estranho ter funcionado por conta do encoding, com latin1, eu sempre
>> recebia texto não aproveitável.
>>
>>
>> abs
>> Roberto
>>
>>
>>
>> 2012/10/31 Daniel Marcelino <dmsilva.br em gmail.com>
>>
>>> Resolvido:
>>> você precisa acrescentar os seguintes paramentros nos comandos que eu
>>> enviei anteriormente:
>>>
>>> fileEncoding = "latin1", as.is = TRUE
>>>
>>>
>>> Você pode também abrir os dados de seu computador assim:
>>>
>>> data1 <- read.delim(file.choose(),header=TRUE,sep="\t",  fill=TRUE,
>>> fileEncoding = "latin1", as.is = TRUE)
>>>
>>>
>>>
>>> 2012/10/31 Daniel Marcelino <dmsilva.br em gmail.com>
>>>
>>>> E se tudo der certo,
>>>> corte a conexao depois.
>>>>
>>>> unlink(temp)
>>>>
>>>>
>>>>
>>>> 2012/10/31 Daniel Marcelino <dmsilva.br em gmail.com>
>>>>
>>>>> Tenta assim:
>>>>>
>>>>>
>>>>> temp <- tempfile()
>>>>> > download.file("
>>>>> http://arquivos.portaldatransparencia.gov.br/PortalTransparenciaEscolheTipoDePlanilha.asp?origem=Servidores&Planilha=0
>>>>> ",temp)
>>>>> trying URL '
>>>>> http://arquivos.portaldatransparencia.gov.br/PortalTransparenciaEscolheTipoDePlanilha.asp?origem=Servidores&Planilha=0
>>>>> '
>>>>> Content type 'application/x-zip-compressed' length 284100659 bytes
>>>>> (270.9 Mb)
>>>>> opened URL
>>>>>
>>>>> ===============================================================================
>>>>> =====
>>>>>
>>>>> data1 <- read.delim(unz(temp,
>>>>> "20120930_Servidores.csv"),header=TRUE,sep="\t",  fill=TRUE)
>>>>>
>>>>> data2 <- read.delim(unz(temp,
>>>>> "20120930_Observacoes_Servidores.csv"),header=TRUE,sep="\t",  fill=TRUE)
>>>>>
>>>>> data3 <- read.delim(unz(temp,
>>>>> "20120930_Remuneracao_Servidores.csv"),header=TRUE,sep="\t",  fill=TRUE)
>>>>>
>>>>> data4 <- read.delim(unz(temp,
>>>>> "20120930_Jetom_Servidores.csv"),header=TRUE,sep="\t",  fill=TRUE)
>>>>>
>>>>>
>>>>> Daniel
>>>>>
>>>>>
>>>>>
>>>>> 2012/10/31 Roberto de Pinho <robertodepinho em gmail.com>
>>>>>
>>>>>> obrigado.
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2012/10/31 Paulo Justiniano <paulojus em leg.ufpr.br>
>>>>>>
>>>>>>> O site do leg está em uma rapida manutencao e já retorna
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, 31 Oct 2012, Roberto de Pinho wrote:
>>>>>>>
>>>>>>>  o guia foi movido?
>>>>>>>> http://www.leg.ufpr.br/r-br-**guia<http://www.leg.ufpr.br/r-br-guia>
>>>>>>>>
>>>>>>>>                                                                Not
>>>>>>>> Found
>>>>>>>>
>>>>>>>> The requested URL /r-br-guia was not found on this server.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/10/31 Walmes Zeviani <walmeszeviani em gmail.com>
>>>>>>>>       Não envie arquivos anexados nas mensagens. Forneça um CMR.
>>>>>>>> Para isso hospede seu arquivo na web ou passe o dput() do mesmo.
>>>>>>>>       Leia o guia de postagem.
>>>>>>>>
>>>>>>>>       À disposição.
>>>>>>>>       Walmes.
>>>>>>>>
>>>>>>>>       ==============================**
>>>>>>>> ==============================**==============
>>>>>>>>       Walmes Marques Zeviani
>>>>>>>>       LEG (Laboratório de Estatística e Geoinformação, 25.450418 S,
>>>>>>>> 49.231759 W)
>>>>>>>>       Departamento de Estatística - Universidade Federal do Paraná
>>>>>>>>       fone: (+55) 41 3361 3573
>>>>>>>>       VoIP: (3361 3600) 1053 1173
>>>>>>>>       e-mail: walmes em ufpr.br
>>>>>>>>       skype: walmeszeviani
>>>>>>>>       twitter: @walmeszeviani
>>>>>>>>       homepage: http://www.leg.ufpr.br/~walmes
>>>>>>>>       linux user number: 531218
>>>>>>>>       ==============================**
>>>>>>>> ==============================**==============
>>>>>>>>
>>>>>>>>
>>>>>>>>       2012/10/31 Fátima Lima Paula <fatima.lima.paula em gmail.com>
>>>>>>>>             Tente salvar o arquivo em .csv (separado por vírgulas)
>>>>>>>> e leia peloread.csv2.
>>>>>>>> Acho que vai conseguir.
>>>>>>>> Fátima
>>>>>>>>
>>>>>>>> Em 31 de outubro de 2012 11:22, Roberto de Pinho <
>>>>>>>> robertodepinho em gmail.com> escreveu:
>>>>>>>>       Caros,
>>>>>>>> Estou tentando ler o arquivo de servidores disponível no portal da
>>>>>>>> transparência.
>>>>>>>>
>>>>>>>> (
>>>>>>>> http://arquivos.**portaldatransparencia.gov.br/**
>>>>>>>> PortalTransparenciaEscolheTipo**DePlanilha.asp?origem=**
>>>>>>>> Servidores&Planilha=0<http://arquivos.portaldatransparencia.gov.br/PortalTransparenciaEscolheTipoDePlanilha.asp?origem=Servidores&Planilha=0>
>>>>>>>>  - mais de 200MB)
>>>>>>>>
>>>>>>>> É um CSV  codificado em UTF-16.
>>>>>>>>
>>>>>>>> No entanto, ele reconhece prematuramente fins de linhas em algumas
>>>>>>>> linhas quando encontra campos com nulo [00 00]. Há
>>>>>>>> valores não nulos não sendo lidos após campos nulos que provocam
>>>>>>>> o reconhecimento de fim de linha.
>>>>>>>>
>>>>>>>> Alguém saberia como poderia fazer com que o R possa ler este
>>>>>>>> arquivo?
>>>>>>>>
>>>>>>>> Estou lendo o arquivo com:
>>>>>>>>
>>>>>>>> servidores = read.table("teste.csv", header = T, sep="\t",quote="",
>>>>>>>> **stringsAsFactors=T,**fileEncoding="UTF-16", fill=T)
>>>>>>>>
>>>>>>>> o fill=T estou sando para evitar que dê erro de diferente numero de
>>>>>>>> campos.
>>>>>>>>
>>>>>>>> Envio, em anexo, um extrato das primeiras linhas do arquivo.
>>>>>>>>
>>>>>>>>
>>>>>>>> Obrigado pela atenção.
>>>>>>>>
>>>>>>>> ====
>>>>>>>> Sequencia de bytes que provocam o reconhecimento de nova linha:
>>>>>>>>
>>>>>>>> 09 00 00 00 09 00 00 00 09 00 00 00 09 00 00 00 09 00 00 00 09 00
>>>>>>>> 00 00 09 00 00 00 09 00 00 00 09 00 00 00 09 00 00
>>>>>>>> 00 09 00 00 00 09 00 00 00 09 00
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Roberto de Pinho
>>>>>>>> robertodepinho em gmail.com
>>>>>>>> http://www.ascoisas.com http://lattes.cnpq.br/**4816166073408660<http://lattes.cnpq.br/4816166073408660>
>>>>>>>>
>>>>>>>>
>>>>>>>> ______________________________**_________________
>>>>>>>> R-br mailing list
>>>>>>>> R-br em listas.c3sl.ufpr.br
>>>>>>>> https://listas.inf.ufpr.br/**cgi-bin/mailman/listinfo/r-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<http://www.leg.ufpr.br/r-br-guia>)
>>>>>>>> e forneça código mínimo reproduzível.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ______________________________**_________________
>>>>>>>> R-br mailing list
>>>>>>>> R-br em listas.c3sl.ufpr.br
>>>>>>>> https://listas.inf.ufpr.br/**cgi-bin/mailman/listinfo/r-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<http://www.leg.ufpr.br/r-br-guia>)
>>>>>>>> e forneça código mínimo reproduzível.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ______________________________**_________________
>>>>>>>> R-br mailing list
>>>>>>>> R-br em listas.c3sl.ufpr.br
>>>>>>>> https://listas.inf.ufpr.br/**cgi-bin/mailman/listinfo/r-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<http://www.leg.ufpr.br/r-br-guia>)
>>>>>>>> e forneça código mínimo reproduzível.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Roberto de Pinho
>>>>>>>> robertodepinho em gmail.com
>>>>>>>> http://www.ascoisas.comhttp://**lattes.cnpq.br/**4816166073408660<http://lattes.cnpq.br/4816166073408660>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Roberto de Pinho
>>>>>> robertodepinho em gmail.com
>>>>>> http://www.ascoisas.com
>>>>>> http://lattes.cnpq.br/4816166073408660
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Roberto de Pinho
>> robertodepinho em gmail.com
>> http://www.ascoisas.com
>> http://lattes.cnpq.br/4816166073408660
>>
>>
>> _______________________________________________
>> 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}
>
> _______________________________________________
> 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.
>



-- 
Roberto de Pinho
robertodepinho em gmail.com
http://www.ascoisas.com
http://lattes.cnpq.br/4816166073408660
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121031/ca86ad7d/attachment.html>


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