ISOSurvey_Parser.R
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#------------------------------------------------------------------------------------------------------
#-----------------------------Parser Excel - ISO survey------------------------------------------------
#------------------------------------------------------------------------------------------------------
#-----------------------------Library tests / install--------------------------------------------------
#' Install and load required libraries
#'
#' This function checks if every required library is installed to be loaded, if not they will be installed and then loaded.
#' Libraries installed:
#' xlsx to parse excel files like ISO survey source format
LoadParserLibraries <- function(){
if (!require("xlsx"))
{
install.packages("xlsx")
if (!require("xlsx")) stop("Error while loading package [xlsx]")
}
}
#-----------------------------Read from file-----------------------------------------------------------
#' Get data frame from an excel file
#'
#' Check if the file exists and then parse it into a data.frame
#' @param file path to excel file
#' @param sheet index of sheet to parse
#'
#' @return data.frame
ParseExcelFileRaw <- function(file, sheet){
if (!file.exists(file)) {
stop(paste("Error, file [", file, "] not found"))
}
dataset <- read.xlsx2(file, sheet, header = TRUE)
dataset
}
#' Process raw data from ISO survey
#'
#' ...
#' @param dataset.raw raw data from ISO Survey excel file
#'
#' @return data.frame
ProccesISOSurveyRaw <- function(dataset.raw){
#Complete
}
#ISO_survey_certificates_countries <- read.xlsx2(paste(getwd(), "/Data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", sep = ""), 1)
#ISO_survey_sites_countries <- read.xlsx2(paste(getwd(), "/Data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", sep = ""), 2)
#ISO_survey_certificates_sector <- read.xlsx2(paste(getwd(), "/Data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", sep = ""), 3)