Example #1
0
        /// <summary>
        /// Counts overlapping bits that are set to true
        /// </summary>
        public static int Overlap(Interest i1, Interest i2)
        {
            int overlap = 0;

            if (i1.CareerAdvice && (i1.CareerAdvice == i2.CareerAdvice))
            {
                overlap++;
            }
            if (i1.SkillsGrowth && (i1.SkillsGrowth == i2.SkillsGrowth))
            {
                overlap++;
            }
            if (i1.ExpandNetwork && (i1.ExpandNetwork == i2.ExpandNetwork))
            {
                overlap++;
            }
            if (i1.LifeAdvice && (i1.LifeAdvice == i2.LifeAdvice))
            {
                overlap++;
            }
            if (i1.SocialConnection && (i1.SocialConnection == i2.SocialConnection))
            {
                overlap++;
            }
            if (i1.LearnDiscipline && (i1.LearnDiscipline == i2.LearnDiscipline))
            {
                overlap++;
            }
            if (i1.LearnTech && (i1.LearnTech == i2.LearnTech))
            {
                overlap++;
            }
            if (i1.NewCareer && (i1.NewCareer == i2.NewCareer))
            {
                overlap++;
            }

            return(overlap);
        }
Example #2
0
        /// <summary>
        /// Survey parsed out into a text and read into a collection of objects.  This was used to convert the
        /// strings from the survey into a collection of bits for each item.  Manual process to export the data,
        /// create a text file and parse it out then re-paste it back into excel.
        /// Sample inputs:
        ///     Career advice;Skills, growth, problem solving;Social connection;Learning about other career journeys;
        ///     Career advice; Skills, growth, problem solving; Expanding my network;Learning about other career journeys;
        ///     Social connection; Skills, growth, problem solving; Career advice; Just want to elaborate that I can offer an EIC perspective on some of these topics; Learning about other career journeys;
        /// Note that there is no fixed order for the fields.
        /// </summary>
        private static void ParseSurveyFile(string filename)
        {
            StringBuilder stringBuilder = new StringBuilder();

            var fileStream = new StreamReader("c:\\temp\\" + filename + ".txt");  // You know this is fancy if you're reading files out of temp.

            while (!fileStream.EndOfStream)
            {
                Interest interest = new Interest();
                string   line     = fileStream.ReadLine();

                // Maintain blank lines so that output rows line up with input rows
                if (String.IsNullOrEmpty(line))
                {
                    stringBuilder.AppendLine(interest.ToString());
                    continue;
                }

                var items = line.Split(";");

                foreach (var item in items)
                {
                    var target = item.Trim();

                    // Convert to individual fields
                    if (target.Contains("Career advice"))
                    {
                        interest.CareerAdvice = true;
                    }
                    else if (target.Contains("Skills, growth, problem solving"))
                    {
                        interest.SkillsGrowth = true;
                    }
                    else if (target.Contains("Expanding my network"))
                    {
                        interest.ExpandNetwork = true;
                    }
                    else if (target.Contains("Life advice"))
                    {
                        interest.LifeAdvice = true;
                    }
                    else if (target.Contains("Social connection"))
                    {
                        interest.SocialConnection = true;
                    }
                    else if (target.Contains("Learning a new discipline"))
                    {
                        interest.LearnDiscipline = true;
                    }
                    else if (target.Contains("Learning a new technology"))
                    {
                        interest.LearnTech = true;
                    }
                    else if (target.Contains("Exploring a new career journey") || target.Contains("Learning about other career journeys"))
                    {
                        interest.NewCareer = true;
                    }
                    else if (!String.IsNullOrEmpty(target))  // only one freeform field was present
                    {
                        interest.Other = target;
                    }
                }

                stringBuilder.AppendLine(interest.ToString());
            }

            var streamWriter = new StreamWriter("c:\\temp\\" + filename + ".csv");

            streamWriter.Write(stringBuilder.ToString());
            streamWriter.Close();
            Console.WriteLine(stringBuilder.ToString());
        }