Skip to content

Commit

Permalink
Merge pull request #35 from JGCRI/output
Browse files Browse the repository at this point in the history
Fix up a few issues I found when running the full package for the first time.
  • Loading branch information
rplzzz authored Sep 20, 2017
2 parents 9787a0c + a888ea6 commit 11aeaf8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: iamrpt
Title: Convert GCAM results to the format required by various IAM experiment databases
Version: 0.0.0.9000
Version: 0.1.0
Authors@R: c(
person("Robert", "Link", email = "[email protected]", role = c("aut", "cre")),
person("Xavier", "Gutierrez", email = "[email protected]", role = c("aut"))
Expand Down
10 changes: 5 additions & 5 deletions R/mcl.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ generate <- function(scenctl,
tabs = getOption('iamrpt.tabs', TRUE),
outputdir = getwd())
{
scenctl <- readr::read_csv(scenctl)
varctl <- readr::read_csv(varctl)
suppressMessages({scenctl <- readr::read_csv(scenctl)})
suppressMessages({varctl <- readr::read_csv(varctl)})

validatectl(scenctl, varctl)

Expand All @@ -164,15 +164,15 @@ generate <- function(scenctl,


if(fileformat == 'XLSX') {
output_xlsx(rslts, tabs, dbloc)
output_xlsx(rslts, tabs, outputdir)
}
else if(fileformat == 'CSV') {
output_csv(rslts, tabs, dbloc)
output_csv(rslts, tabs, outputdir)
}
else {
warning('Unknown file format ', fileformat, ' requested. ',
'Writing as CSV.')
output_csv(rslts, tabs, dbloc)
output_csv(rslts, tabs, outputdir)
}

message('FIN.')
Expand Down
5 changes: 4 additions & 1 deletion R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ output_csv <- function(rslts, tabs, dirname)
if(tabs) {
## One file for each table
for(tblname in names(rslts)) {
filename <- alternate_filename(file.path(dirname, paste0(tblname, '.csv')))
filename <- alternate_filename(file.path(dirname, paste0(tblname,
'.csv')))
message('Writing file ', filename)
readr::write_csv(rslts[[tblname]], filename)
}
}
else {
## Single file in PITA format.
filename <- alternate_filename(file.path(dirname, 'iamrpt.csv'))
message('Writing file ', filename)
fcon <- file(filename, 'w')
line1 <- TRUE
for(tblname in names(rslts)) {
Expand Down

0 comments on commit 11aeaf8

Please sign in to comment.