How to remove unicodes "<U+2197>", "<U+2198" and "•" from a string?

Hi,
I've scraped some data from a pdf file and got strings of each pdf file pages where nearby each numeric value stands some unicode (<U+2197>, <U+2198 or •).

Is it possible to eliminate those unicodes or not? If yes, what functions should I use?

Already tried to remove them with str_extract/str_remove, but it only bring me a na values.

``` r
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.0.3
#> Warning: package 'tidyr' was built under R version 4.0.3
#> Warning: package 'readr' was built under R version 4.0.2
#> Warning: package 'dplyr' was built under R version 4.0.3
#> Warning: package 'stringr' was built under R version 4.0.3
#> Warning: package 'forcats' was built under R version 4.0.3
library(pdftools)
#> Warning: package 'pdftools' was built under R version 4.0.3
#> Using poppler version 0.73.0

PDF_gruodis <- pdf_text("~/oberhaus/NT-kainos-2020-gruodis.pdf") %>% str_split("\r\n") 

# Panaikina header ir footer is visu pdf psl.
for(i in 3) {
  PDF_gruodis[[i]] <- PDF_gruodis[[i]][-1]
  a1 <- length(PDF_gruodis[[1]]) #finds length of the page
  a2 <- length(PDF_gruodis[[2]])
  a3 <- length(PDF_gruodis[[3]])
  b1 <- a1-5 #finds number of line without footer
  b2 <- a2-5
  b3 <- a3-2
  PDF_gruodis[[1]] <- PDF_gruodis[[1]][-b1:-a1] #removes
  PDF_gruodis[[2]] <- PDF_gruodis[[2]][-b2:-a2]
  PDF_gruodis[[3]] <- PDF_gruodis[[3]][-b3:-a3]
} 


pdf_sq <- str_squish(PDF_gruodis) 
#> Warning in stri_replace_all_regex(string, pattern,
#> fix_replacement(replacement), : argument is not an atomic vector; coercing
pdf_split <- strsplit(pdf_sq, split= "\\,\\s\\\"") 

for(i in 1:length(pdf_split)) {
  pdf_split[[i]][1] <- pdf_split[[i]][1] %>%
    stringr::str_extract("(?<=c[:punct:]\\\").*") 
}


for(i in 1:length(pdf_split)) {
  for(j in 1:length(pdf_split[[i]])) {
    pdf_split[[i]][j] <- pdf_split[[i]][j] %>%
      stringr::str_extract(".*(?=\")") 
  }
}
pdf_split[[1]]
#>  [1] "Nekilnojamojo turto kainos Lietuvoje 2020 m. gruodis"                                                                                                           
#>  [2] " 1 kambario 2 kambariu 3 kambariu 4 ir daugiau kamb."                                                                                                           
#>  [3] " Butu kainos (Eur/m2) nuo iki nuo iki nuo iki nuo iki"                                                                                                          
#>  [4] " VILNIUS"                                                                                                                                                       
#>  [5] "Centras, Senamiestis, Užupis"                                                                                                                                   
#>  [6] " naujos statybos butai (daline apdaila) 2.600 <U+2197> 3.700 <U+2197> 2.500 <U+2197> 4.100 <U+2197> 2.400 <U+2197> 4.600 <U+2197> 2.300 <U+2197> 4.600 <U+2197>"
#>  [7] " senos statybos namuose renovuoti butai 2.000 <U+2197> 3.700 • 1.870 <U+2197> 4.000 • 1.800 <U+2197> 4.300 <U+2197> 1.750 <U+2197> 4.300 •"                     
#>  [8] " senos statybos namuose nerenovuoti butai 1.600 • 2.700 • 1.520 • 2.500 • 1.470 • 2.300 • 1.400 • 2.200 •"                                                      
#>  [9] "Prestižiniai rajonai (Antakalnis, Naujamiestis, Žverynas)"                                                                                                      
#> [10] " naujos statybos butai (daline apdaila) 2.150 <U+2197> 3.200 • 2.050 <U+2197> 3.500 <U+2197> 1.970 <U+2197> 3.900 <U+2197> 1.880 <U+2197> 3.900 <U+2197>"       
#> [11] " senos statybos namuose renovuoti butai 1.550 • 3.000 • 1.470 • 3.100 • 1.420 • 3.400 • 1.370 • 3.500 •"                                                        
#> [12] " senos statybos namuose nerenovuoti butai 1.400 • 2.200 • 1.300 • 2.000 • 1.250 • 1.950 • 1.200 • 1.900 •"                                                      
#> [13] "Gyvenamieji rajonai (Baltupiai, Fabijoniškes, Jeruzale, Justiniškes, Karoliniškes, Lazdynai, Pašilaiciai, Pilaite, Santariškes, Šeškine,"                       
#> [14] "Viršuliškes, Žirmunai)"                                                                                                                                         
#> [15] " naujos statybos butai (daline apdaila) 1.400 <U+2197> 1.850 <U+2197> 1.280 <U+2197> 1.800 <U+2197> 1.200 • 1.770 <U+2197> 1.200 <U+2197> 1.700 <U+2197>"       
#> [16] " senos statybos butai plytiniuose namuose 1.520 <U+2197> 1.750 <U+2197> 1.320 <U+2197> 1.680 <U+2197> 1.170 <U+2197> 1.560 <U+2197> 1.100 <U+2197> 1.320 •"     
#> [17] " senos statybos butai blokiniuose namuose 1.390 <U+2197> 1.600 <U+2197> 1.200 • 1.530 <U+2197> 1.020 • 1.360 <U+2197> 1.000 <U+2197> 1.230 •"                   
#> [18] "Kiti rajonai (Grigiškes, Naujoji Vilnia, Ž. Paneriai ir kt.)"                                                                                                   
#> [19] " naujos statybos butai (daline apdaila) 1.200 • 1.350 • 1.150 • 1.300 • 1.100 • 1.300 <U+2197> 1.100 • 1.250 •"                                                 
#> [20] " standartiniai butai 920 • 1.300 • 910 • 1.270 <U+2197> 900 • 1.250 <U+2197> 850 • 1.200 <U+2197>"                                                              
#> [21] " KAUNAS"                                                                                                                                                        
#> [22] "Centras, Senamiestis"                                                                                                                                           
#> [23] " naujos statybos butai (daline apdaila) 1.650 • 2.100 • 1.550 • 2.100 • 1.500 • 2.200 • 1.480 • 2.200 •"                                                        
#> [24] " senos statybos namuose renovuoti butai 1.420 • 1.950 • 1.320 • 2.100 • 1.250 • 2.250 • 1.200 • 2.250 •"                                                        
#> [25] " senos statybos namuose nerenovuoti butai 1.200 • 1.600 • 1.120 • 1.550 • 1.080 • 1.500 • 1.050 • 1.480 •"                                                      
#> [26] "Žaliakalnis"                                                                                                                                                    
#> [27] " naujos statybos butai (daline apdaila) 1.450 • 1.800 • 1.400 • 1.850 • 1.400 • 1.900 • 1.380 • 1.900 •"                                                        
#> [28] " senos statybos namuose renovuoti butai 1.220 • 1.720 <U+2198> 1.150 • 1.700 <U+2198> 1.090 • 1.750 • 1.050 • 1.750 •"                                          
#> [29] " senos statybos namuose nerenovuoti butai 1.050 • 1.470 • 960 • 1.450 • 920 • 1.400 • 870 • 1.350 •"                                                            
#> [30] "Gyvenamieji rajonai"                                                                                                                                            
#> [31] " naujos statybos butai (daline apdaila) 1.280 <U+2197> 1.600 • 1.160 • 1.550 • 1.100 <U+2197> 1.530 • 1.100 <U+2197> 1.480 •"                                   
#> [32] " senos statybos namuose renovuoti butai 930 • 1.320 • 900 • 1.300 • 870 <U+2197> 1.250 • 830 <U+2197> 1.150 •"                                                  
#> [33] " senos statybos namuose nerenovuoti butai 800 • 1.050 • 780 <U+2197> 1.020 <U+2197> 740 • 960 <U+2197> 700 • 900 •"                                             
#> [34] "Priemiescio rajonai"                                                                                                                                            
#> [35] " naujos statybos butai (daline apdaila) 950 • 1.050 • 880 • 1.000 • 850 • 980 • 830 • 950 •"                                                                    
#> [36] " KLAIPEDA"                                                                                                                                                      
#> [37] "Centras, Senamiestis, prestižiniai rajonai"                                                                                                                     
#> [38] " naujos statybos butai (daline apdaila) 1.600 • 1.900 • 1.550 • 1.900 • 1.480 <U+2197> 2.000 • 1.450 • 2.000 •"                                                 
#> [39] " senos statybos namuose renovuoti butai 1.200 • 2.000 • 1.150 • 2.050 • 1.100 • 2.150 • 1.070 • 2.150 •"                                                        
#> [40] " senos statybos namuose nerenovuoti butai 1.000 • 1.460 • 970 • 1.420 • 930 • 1.380 • 900 • 1.340 •"                                                            
#> [41] "Gyvenamieji rajonai"                                                                                                                                            
#> [42] " naujos statybos butai (daline apdaila) 1.280 <U+2197> 1.580 • 1.220 <U+2197> 1.550 <U+2197> 1.130 <U+2197> 1.530 <U+2197> 1.100 <U+2197> 1.480 •"              
#> [43] " senos statybos namuose renovuoti butai 950 <U+2197> 1.320 <U+2197> 900 • 1.320 <U+2197> 850 • 1.250 • 820 • 1.130 <U+2197>"                                    
#> [44] " senos statybos namuose nerenovuoti butai 800 • 1.050 <U+2197> 720 • 1.000 <U+2197> 680 • 950 <U+2197> 660 • 860 •"                                             
#> [45] " ŠIAULIAI"                                                                                                                                                      
#> [46] "Centras"                                                                                                                                                        
#> [47] " naujos statybos butai (daline apdaila) 1.200 • 1.350 • 1.200 • 1.350 • 1.150 • 1.400 • 1.150 • 1.400 •"                                                        
#> [48] " senos statybos butai 680 • 1.150 • 690 • 1.240 • 690 • 1.260 • 660 • 1.200 •"                                                                                  
#> [49] "Gyvenamieji rajonai"                                                                                                                                            
#> [50] " naujos statybos butai (daline apdaila) 950 • 1.200 • 950 • 1.100 • 950 • 1.100 • 950 • 1.100 •"                                                                
#> [51] " senos statybos butai 560 • 840 <U+2197> 550 • 890 <U+2197> 550 • 890 <U+2197> 540 • 840 •"                                                                     
#> [52] " PANEVEŽYS"                                                                                                                                                     
#> [53] "Centras"                                                                                                                                                        
#> [54] " naujos statybos butai (daline apdaila) 1.200 • 1.350 • 1.200 • 1.350 • 1.150 • 1.400 • 1.150 • 1.400 •"                                                        
#> [55] " senos statybos butai 670 • 1.070 • 670 • 1.160 <U+2198> 660 • 1.180 <U+2197> 640 • 1.150 •"                                                                    
#> [56] "Gyvenamieji rajonai"                                                                                                                                            
#> [57] " naujos statybos butai (daline apdaila) 950 • 1.150 • 950 • 1.100 • 950 • 1.100 • 900 • 1.050 •"                                                                
#> [58] " senos statybos butai 550 • 820 • 540 • 880 • 540 • 880 • 530 • 840 •"                                                                                          
#> [59] " DRUSKININKAI"                                                                                                                                                  
#> [60] "Centras"                                                                                                                                                        
#> [61] " naujos statybos butai (pilna apdaila) 1.650 • 2.500 • 1.600 • 2.500 • 1.550 • 2.300 • 1.700 • 2.100 •"                                                         
#> [62] " senos statybos butai 850 • 1.350 • 750 • 1.300 • 700 • 1.200 • 680 • 1.100 •"                                                                                  
#> [63] "Gyvenamieji rajonai"                                                                                                                                            
#> [64] " naujos statybos butai (pilna apdaila) 1.050 • 1.400 • 1.000 • 1.300 • 960 • 1.250 • 950 • 1.200 •"                                                             
#> [65] " senos statybos butai 750 • 1.000 • 650 • 950 • 620 • 900 • 600 • 820 •"

Created on 2021-01-25 by the reprex package (v0.3.0)

suppressPackageStartupMessages({
  library(stringr)
})
pattern = "\\<U+2197>|\\<U+2198|•"
text <- "senos statybos butai 750 • 1.000 • 650 • 950 • 620 • 900 • 600 • 820 •"
str_remove_all(text,pattern)
#> [1] "senos statybos butai 750  1.000  650  950  620  900  600  820 "
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

thank you for an answer!