0

I exported a spreadsheet from Excel to a database and it came with whites in some field's names. I did search for a solution before, but I couldn't find a workable method to strip whites from a column's name, only for the column itself. I'm using R to send queries to the server. This is what my fields look like:

[1] "DATA GERACAO"             "HORA_GERACAO"            
 [3] "ANO ELEICAO"              "NUM_TURNO"               
 [5] "DESCRICAO ELEICAO"        "SIGLA_UF"                
 [7] "SIGLA UE"                 "DESCRICAO_UE"            
 [9] "CODIGO CARGO"             "NUMERO_CANDIDATO"        
[11] "SEQUENCIAL CANDIDATO"     "NOME_CANDIDATO"          
[13] "NOME_URNA_CANDIDATO"      "DESCRICAO_CARGO"         
[15] "COD_SIT_CAND_SUPERIOR "   "DESC_SIT_CAND_SUPERIOR " 
[17] "COD_SITUACAO_CANDIDATURA" "DES_SITUACAO_CANDIDATURA"
[19] "COD_SIT_TOT_TURNO"        "DESC_SIT_TOT_TURNO"      
[21] "CODIGO_LEGENDA"           "SIGLA_PARTIDO"           
[23] "NOME_PARTIDO"             "SEQUENCIAL_LEGENDA "     
[25] "NOME_LEGENDA"             "COMPOSICAO_LEGENDA"      
[27] "TOTAL_VOTOS " 

I want to remove the white spaces, because it might be a problem when I need to call those fields later on. I've tried the following solution, and got the error message below. Any suggestion?

dbGetQuery(db, "UPDATE Table2 SET TOTAL_VOTOS = TRIM(Replace(Replace(Replace(TOTAL_VOTOS ,'\t',''),'\n',''),'\r',''))")

Error in sqliteSendQuery(con, statement, bind.data) : 
  error in statement: no such column: TOTAL_VOTOS
hatirlatici
  • 1,598
  • 2
  • 13
  • 24
daniel
  • 1,186
  • 2
  • 12
  • 21
  • There is no whitespace in the column names you've shown. – CL. Jul 20 '15 at 09:17
  • Where exactly is the whitespace in `"DATA_GERACAO"`? – CL. Jul 20 '15 at 17:49
  • @CL. Not in that field "DATA_GERACAO", but in the example I'm using for the query: "TOTAL_VOTOS " . Or in this one: "DESC_SIT_CAND_SUPERIOR ". Can you notice the space? I certainly can handle it in R by replacing the correct column names, but I'd love to know the SQL way of doing this directly in the server. – daniel Jul 20 '15 at 20:05
  • Sorry, I overlooked those. – CL. Jul 20 '15 at 20:57

0 Answers0