Ejemplo n.º 1
0
        public bool GenerateConditionals(string inputDataFile, string inputDescFile)
        {
            using (var reader = new ConditionalDataReader(inputDataFile))
            {
                string currRow = null;
                currRow = reader.GetNextRow();
                if(currRow != null)
                {
                    SetDimensions(inputDescFile);
                }
                else
                {
                    return false;
                }
                currRow = reader.GetNextRow();

                for(int i = 0; i < DimenionNames.Count; i++)
                {
                    CreateCategoryCombinations(i);
                }
                while(currRow != null)
                {
                    WriteNextConditional(currRow);
                    currRow = reader.GetNextRow();
                }

                foreach(var currTable in CondCollection)
                {
                    using (var writer = new OutputFileWriter(
                        Constants.DATA_DIR + "Census" + currTable.Key + ".csv"))
                    {
                        writer.WriteToFile("Conditional,Count");
                        foreach(var currPair in currTable.Value)
                        {
                            writer.WriteToFile(
                                ((KeyValPair)currPair.Value).Category
                                + "," + ((KeyValPair)currPair.Value)
                                            .Value.ToString());
                        }
                    }
                }
            }
            return true;
        }
Ejemplo n.º 2
0
 private void SetDimensions(string inputDescFile)
 {
     using (var descReader = new ConditionalDataReader(inputDescFile))
     {
         string dimStr = descReader.GetNextRow();
         dimStr.TrimEnd();
         while(dimStr != null)
         {
             string[] currTok = dimStr.Split(
                 Constants.COLUMN_DELIMETER[0]);
             CondCollection.Add(currTok[0], new Dictionary<string, KeyValPair>());
             var curCats = new List<string>();
             foreach(string curCat in currTok)
             {
                 if(curCat != null && curCat != "")
                 {
                     curCats.Add(curCat);
                 }
             }
             DimenionNames.Add(curCats);
             dimStr = descReader.GetNextRow();
         }
     }
 }