OHDSI Home | Forums | Wiki | Github

Running runCohortDiagnostics - "Error - Cannot open file for writing"

I am running into this error
Error: Cannot open file for writing:

  • '~Desktop\PhenotypeLibraryDiagnosticsOutput\diagnosticsExport\concept_set.csv

This error happens when I run runCohortDiagnostics and using incremental = TRUE
I think this argument will help the library to create inclusion stats which what I need.

I believe that this error happens because the file is trying to append but not sure why it is happening in my code or if someone else experienced this error.
@gowtham : Any idea why I am getting this error?

I included below the function that I run:
CohortDiagnostics::runCohortDiagnostics(
packageName = “PhenotypeLibraryDiagnostics”,
cohortToCreateFile = “settings/cohortDescription.csv”,
connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
oracleTempSchema = oracleTempSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
inclusionStatisticsFolder = outputFolder,
exportFolder = file.path(outputFolder, “diagnosticsExport”),
databaseId = databaseId,
databaseName = databaseName,
databaseDescription = databaseDescription,
runInclusionStatistics = TRUE,
runIncludedSourceConcepts = FALSE,
runOrphanConcepts = FALSE,
runTimeDistributions = TRUE,
runBreakdownIndexEvents = TRUE,
runIncidenceRate = TRUE,
runCohortOverlap = TRUE,
runCohortCharacterization = TRUE,
runTemporalCohortCharacterization = TRUE,
runVisitContext = TRUE,
minCellCount = 2,
incremental = TRUE,
incrementalFolder = incrementalFolder,

                                        cohortIds=dx_cohortsid)

me too,wait!

Just as an idea: did you check concept_set.csv? Does it exist? Also, incremental = TRUE is used when you re-run your analysis to leverage previously created files (cohorts, etc.). Not really needed if you run you analysis for the first time.

I can’t found concept_set.csv in outputFolder, This is the second time I run this program, and one of the analysis is very time-consuming (about 11 hours)

maybe create a blank file and try again.

Error: Cannot open file for writing:

  • ‘F:\PhenotypeLibraryDiagnosticsOutput\incremental\InstantiatedCohorts.csv’
    An error report has been created at F:/PhenotypeLibraryDiagnosticsOutput/errorReportR.txt
    Called from: eval(previousErrorHandler)

the InstantiatedCohorts.csv file exists

Thanks @lychenus . What happens in my case is getting the same error but every time I get it at a different file. So the last time happened when the functions was trying to read conceptset.csv file, and another time the error happened at index_event_breakdown.csv. My only workaround will be batching my cohorts. It is odd and I think in my env the function that reads the files should pass FALSE to Lazy reading argument

t