1
By downloading the database of values of daily and tickets 2019 the portal of transparency http://www.portaltransparencia.gov.br/download-de-dados/viagens, I used the code below to read the daily log file received in the year 2019, but I have received some errors with the fread function and errors with the read.delim function, because in the last case when reading the column "Daily Value" the values are not recognized correctly. Follow the codes with their errors:
rm(list=ls())
library("tidyverse")
library("readr")
library("data.table")
library("stringr")
library("lubridate")
#unzip("2019_20190630_Viagens.zip")
options(datatable.fread.input.cmd.message=FALSE)
Diaria2019_Via <- "iconv -f ISO-8859-1 -t UTF-8 2019_Viagem.csv"
Diaria2019 <- data.table::fread(Diaria2019_Via,dec = ",")
Warning messages:
1: In data.table::fread(Diaria2019_Via, dec = ",") :
Found and resolved improper quoting in first 100 rows. If the fields are not quoted (e.g. field separator does not appear within any field), try quote="" to avoid this warning.
2: In data.table::fread(Diaria2019_Via, dec = ",") :
Stopped early on line 7378. Expected 16 fields but found 18. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<"0000000000015769552";"Realizada";"53000";"Ministério do Desenvolvimento Regional";"53000";"Ministério do Desenvolvimento Regional - Unidades com vínculo direto";"***.043.57*-**";"ARMIN AUGUSTO BRAUN";"";"20190115";"20190116";"São Paulo/SP";"Representar a Secretaria Nacional de Proteção e Defesa Civil - SEDEC, no Seminário "Proteção e Defesa Civil Aplicada", onde Ministrará palestra sobre "Apoio Federal na Resposta a Desastres"; participará reunião com pessoal do Hospital Albert Eins>>
The above message suggests using quote=""
and fill=NULL
, however, none of them works. The code below does the incorrect reading of the Daily Value column:
Diaria_2019 <- read_delim("2019_Viagem.csv",
";", escape_double = FALSE, locale = locale(decimal_mark = ".",encoding = "ISO-8859-1"),
trim_ws = TRUE)
Does anyone suggest any other function that can correctly read the database 2019_Viagem.csv
?
Thanks CGU, congratulations for the work and for the prompt correction of the files!
– fsbmat