# Load-anje paketa
library(tidyverse)
library(tabulizer)
library(readxl)
library(lubridate)
library(patchwork)
library(dplyr)
library(XLConnect)
library(tidyverse)
library(lubridate)
library(xlsx)
library(openxlsx)
library(tools)
putanja <- "Z:/Radne Skupine/Reports/AK-ID"
direktoriji <- list.dirs(putanja, full.names = TRUE,recursive = FALSE)
direktoriji
for (d in 1:length(direktoriji)){
temp_dir = direktoriji[d]
fileovi <- list.files(path=temp_dir,pattern = "\\.xlsx$|\\.xls$")
if (file_ext(fileovi) == "xlsx") {
#fileovi = fileovi %>% filter(file_ext(fileovi[fileovi!="\\.xls"]))
for (f in 1:length(fileovi)){
temp_file = paste(direktoriji[d],fileovi[f],sep="/")
# IF 01.00
temp1 <- read_excel(path = temp_file,sheet = "IF 01.00",range = "A4:C56")
# IF 02.01
temp2 <- read_excel(path = temp_file,sheet = "IF 02.00",range = "A4:C19")
# IF 02.02
temp3 <- read_excel(path = temp_file,sheet = "IF 02.00",range = "A28:C35")
# IF 03.00
temp4 <- read_excel(path = temp_file,sheet = "IF 03.00",range = "A4:C25")
# IF 04.00
temp5 <- read_excel(path = temp_file,sheet = "IF 04.00",range = "A3:C20")
# IF 05.00
temp6 <- read_excel(path = temp_file,sheet = "IF 05.00",range = "A4:C33")
# IF 06.01
temp7 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A6:E12")
# IF 06.02
temp8 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A16:P22")
# IF 06.03
temp9 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A26:E30")
# IF 06.04
temp10 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A34:J38")
# IF 06.05
temp11 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A43:E50")
# IF 06.06
temp12 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A55:J62")
# IF 06.07
temp13 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A67:E75")
# IF 06.08
temp14 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A79:G87")
# IF 06.09
temp15 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A92:C102")
# IF 06.10
temp16 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "B107:G110")
# IF 06.11
temp17 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A115:G129")
# IF 06.12
temp18 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A134:E138")
# IF 06.13
temp19 <- read_excel(path = temp_file,sheet = "IF 06.00",range = "A143:J147")
# sklapanje
temp <- rbind(temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10,temp11,temp12,temp13,temp14,temp15,temp16,temp17,temp18,temp19) #%>% mutate(datum=,subjekt=)
}
}
}
Hi, I am using this piece of code to make a procedure that goes through directories and reads .xlsx files. In directories there are also .xls files that I want to avoid. This piece of code do not get an error just warnings and they are all the same "the condition has length > 1 and only the first element will be used". Can you please help out?
I am trying to get the data from just .xlsx files and if there is such .xlsx file where there is no Sheet 'IF 01.00'
I would like to skip it in the loop. So I would like to skip the .xls files and .xlsx files where is no Sheet 'IF 01.00'
.