Ejemplo n.º 1
0
        public void TestShuffleNoHeaders()
        {
            GenerateTestFileHeadings(false);
            var norm = new ShuffleCSV();

            norm.Analyze(InputName, false, CSVFormat.English);
            norm.ProduceOutputHeaders = false;
            norm.Process(OutputName);

            var    tr = new StreamReader(OutputName.ToString());
            String line;
            IDictionary <String, int> list = new Dictionary <String, int>();

            while ((line = tr.ReadLine()) != null)
            {
                list[line] = 0;
            }

            Assert.AreEqual(6, list.Count);

            tr.Close();

            InputName.Delete();
            OutputName.Delete();
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override sealed bool ExecuteCommand(String args)
        {
            // get filenames
            String sourceID = Prop.GetPropertyString(
                ScriptProperties.RandomizeConfigSourceFile);
            String targetID = Prop.GetPropertyString(
                ScriptProperties.RandomizeConfigTargetFile);

            EncogLogging.Log(EncogLogging.LevelDebug, "Beginning randomize");
            EncogLogging.Log(EncogLogging.LevelDebug, "source file:" + sourceID);
            EncogLogging.Log(EncogLogging.LevelDebug, "target file:" + targetID);

            FileInfo sourceFile = Script.ResolveFilename(sourceID);
            FileInfo targetFile = Script.ResolveFilename(targetID);

            // get formats
            CSVFormat format = Script.DetermineFormat();

            // mark generated
            Script.MarkGenerated(targetID);

            // prepare to normalize
            var norm = new ShuffleCSV {
                Script = Script
            };

            Analyst.CurrentQuantTask = norm;
            norm.Report = new AnalystReportBridge(Analyst);
            bool headers = Script.ExpectInputHeaders(sourceID);

            norm.Analyze(sourceFile, headers, format);
            norm.Process(targetFile);
            Analyst.CurrentQuantTask = null;
            return(norm.ShouldStop());
        }
Ejemplo n.º 3
0
        private static void Shuffle(FileInfo source)
        {
            var shuffle = new ShuffleCSV();

            shuffle.Analyze(source, true, CSVFormat.English);
            shuffle.ProduceOutputHeaders = true;
            shuffle.Process(Config.ShuffledBaseFile);
        }
Ejemplo n.º 4
0
        public void Shuffle(FileInfo fileToShuffle, FileInfo fileToReturn, bool headersExist)
        {
            var shuffle = new ShuffleCSV();

            shuffle.Analyze(fileToShuffle, headersExist, CSVFormat.English);
            shuffle.ProduceOutputHeaders = headersExist;
            shuffle.Process(fileToReturn);
        }
Ejemplo n.º 5
0
        /// <see cref="INetwork.Shuffle"/>
        public INetwork Shuffle()
        {
            var shuffle = new ShuffleCSV();

            shuffle.Analyze(BaseFile, true, CSVFormat.English);
            shuffle.ProduceOutputHeaders = true;
            shuffle.Process(ShuffledFile);

            return(this);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Shuffle the csv file
 /// </summary>
 /// <param name="source"></param>
 public void ShuffleOriginalCsv(FileInfo source, FileInfo destination)
 {
     try
     {
         var shuffle = new ShuffleCSV();
         shuffle.Analyze(source, true, CSVFormat.English);
         shuffle.ProduceOutputHeaders = true;
         shuffle.Process(destination);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }