private IReadOnlyList <PKParameterSensitivity> pkParameterSensitivitiesFrom(string fileFullPath, char delimiter) { using (var reader = new CsvReaderDisposer(fileFullPath, delimiter)) { var pkParameterSensitivityList = new List <PKParameterSensitivity>(); var csv = reader.Csv; var headers = csv.GetFieldHeaders(); if (!headers.ContainsAll(new[] { PARAMETER, PK_PARAMETER, QUANTITY_PATH, VALUE })) { return(pkParameterSensitivityList); } while (csv.ReadNextRecord()) { var pkParameterSensitivity = new PKParameterSensitivity { PKParameterName = csv[PK_PARAMETER], ParameterName = csv[PARAMETER], QuantityPath = csv[QUANTITY_PATH], Value = csv.DoubleAt(VALUE) }; pkParameterSensitivityList.Add(pkParameterSensitivity); } return(pkParameterSensitivityList); } }
private IndividualValuesCache individualValuesCacheFrom(string fileFullPath, char delimiter) { using (var reader = new CsvReaderDisposer(fileFullPath, delimiter)) { var csv = reader.Csv; var headers = csv.GetFieldHeaders(); if (headers.Contains(Constants.Population.INDIVIDUAL_ID_COLUMN)) { return(createIndividualPropertiesFromCSV(csv, headers)); } } return(null); }
public IEnumerable <IndividualResults> ImportFrom(string fileFullPath, IModelCoreSimulation simulation, IImportLogger logger) { //do not define this variables as member variable to be thread safe var cacheQuantitiesValues = new Cache <QuantityValues, List <float> >(); var cacheTimeValues = new Cache <IndividualResults, List <float> >(); try { var individualResults = new Cache <int, IndividualResults>(x => x.IndividualId); using (var reader = new CsvReaderDisposer(fileFullPath)) { var csv = reader.Csv; var headers = csv.GetFieldHeaders(); validateHeaders(headers); //skip the first two indexes that are individual id and time var allQuantityPaths = retrieveQuantityPathsFromHeader(headers, simulation); while (csv.ReadNextRecord()) { int individualId = retrieveParameterId(csv); if (!individualResults.Contains(individualId)) { individualResults.Add(createIndividualResults(individualId, cacheTimeValues)); } addRecordToIndividualResults(individualResults[individualId], allQuantityPaths, csv, cacheTimeValues, cacheQuantitiesValues); } } updateResults(cacheTimeValues, cacheQuantitiesValues); return(individualResults); } catch (Exception e) { logger.AddError(e.FullMessage()); return(Enumerable.Empty <IndividualResults>()); } finally { cacheQuantitiesValues.Clear(); cacheTimeValues.Clear(); } }