Exemple #1
0
 public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
 {
     foreach (var file in files)
     {
         List <List <string> > res = new List <List <string> >();
         bool first = true;
         CsvHelper.ReadCsvByTokens(file, null, (lineN, token) =>
         {
             if (res.Count <= lineN)
             {
                 first = true;
             }
             if (first)
             {
                 res.Add(new List <string>());
                 first = false;
             }
             else
             {
                 res[lineN].Add(token.Substring(token.IndexOf(' ') + 1));
             }
         });
         CsvHelper.WriteCsv(file.Insert(file.Length - 4, "_new"), null, res);
     }
     // dirty hack to avoid further file creation
     throw new Exception("clean done");
 }
Exemple #2
0
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <List <PointPositionsList> > filesPointsPositions = files.Select(file => CsvHelper.ParseFileToPointsPositions(file)).ToList();

            var result    = new List <List <string> >();
            var allPoints = RescaleRelatively(filesPointsPositions)[0];
            List <PointPositionsList.Position> pPositions;

            PointPositionsList.Position pos;
            for (var pointN = 0; pointN < allPoints.Count; ++pointN)
            {
                pPositions = allPoints[pointN].positions;
                for (var posN = 0; posN < pPositions.Count; ++posN)
                {
                    pos = pPositions[posN];
                    if (result.Count <= posN)
                    {
                        result.Add(new List <string> {
                            (1 + 100 * posN).ToString()
                        });
                    }
                    result[posN].Add(string.Format("{0} {1} {2} {3}", pointN, pos.X, pos.Y, pos.Z));
                }
            }
            CsvHelper.WriteCsv(files[0].Insert(files[0].Length - 4, "_rescaled"), null, result);
            // dirty hack to avoid further file creation
            throw new Exception("rescaling done");
        }
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <NamedIndexedList> result = new List <NamedIndexedList>();
            NamedIndexedList        fileWithValues;

            foreach (var file in files)
            {
                fileWithValues = new NamedIndexedList(file);
                CurrentResult  = new List <double>();
                CsvHelper.ReadCsvByLines(file, AddDataLine);
                fileWithValues.SetValuesAutoIndexed(CurrentResult);
            }
            return(result);
        }
Exemple #4
0
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <NamedIndexedList> filesWithValues = files.SelectMany(file => CsvHelper.ParseFileToNamedIndexedLists(file, false)).ToList();
            var i = 0;

            result = new NamedIndexedList("combined")
            {
                IndexedValues = filesWithValues.Select(fv => fv.OnlyValues())
                                .Aggregate((list1, list2) => list1.Intersect(list2).ToList())
                                .ToDictionary(val => i++)
            };
            return(new List <NamedIndexedList> {
                result
            });
        }
        // use result of convertion by SumDistance strategy
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            result = new List <NamedIndexedList>();
            int values_number = int.Parse(parameters);
            List <NamedIndexedList> parsedFiles = files.SelectMany(file => CsvHelper.ParseFileToNamedIndexedLists(file, true)).ToList();

            foreach (var fileWithValues in parsedFiles)
            {
                var i = 0;
                result.Add(new NamedIndexedList(fileWithValues.Name)
                {
                    IndexedValues = fileWithValues.IndexedValues.OrderByDescending(kvPair => kvPair.Value)
                                    .Take(values_number)
                                    .ToDictionary(kvPair => i++, kvPair => (double)kvPair.Key)
                });
            }
            return(result);
        }
        public void Convert(string parameters)
        {
            if (FilesToConvert == null || FilesToConvert.Length == 0)
            {
                throw new Exception("no no no");
            }

            result = ConvertStrategy.ConsumeFiles(parameters, FilesToConvert);

            string resultDir      = Constants.DIR_BASE_OUTPUT + Constants.DIR_CONVERTED;
            string resultFilePath = string.Format("{0}{1}.csv",
                                                  resultDir,
                                                  FilesHelper.GetIncreasedVersionOfFile(
                                                      resultDir,
                                                      string.Format("{0}_{1}", ConvertStrategy.ResultFileName, ConvertId)));

            FilesHelper.WriteLogLine(resultDir + Constants.LOG_FILE_NAME, ConvertStrategy.GetLogSummary(result));
            CsvHelper.WriteCsv(resultFilePath, result, ConvertStrategy.DoIndexesMatter());
        }
Exemple #7
0
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <NamedIndexedList> filesWithValues = files.SelectMany(file => CsvHelper.ParseFileToNamedIndexedLists(file, false)).ToList();

            foreach (var fileWithValues in filesWithValues)
            {
                foreach (int value in fileWithValues.OnlyValues())
                {
                    valuesCounts.TryGetValue(value, out int count);
                    valuesCounts[value] = ++count;
                }
            }
            return(new List <NamedIndexedList> {
                new NamedIndexedList("count")
                {
                    IndexedValues = valuesCounts.OrderByDescending(kvPair => kvPair.Value)
                                    .ToDictionary(kvPair => kvPair.Key, kvPair => (double)kvPair.Value)
                }
            });
        }
 private void CreatePointsIfNeeded()
 {
     if (_points.Count == 0)
     {
         List <double> fscores  = CsvHelper.ParseFileToNamedIndexedLists("C:\\KinectData\\converted\\f_scores.csv", true, ',')[0].OnlyValues();
         double        maxscore = fscores.Max();
         List <Color>  gradient = CreateGradient(Colors.Yellow, Colors.Red);
         bool          special;
         for (int index = 0; index < POINTS_COUNT; index++)
         {
             special = new List <int> {
                 3529, 3015
             }.Select(n => n % 1347).Contains(index);
             Ellipse ellipse = new Ellipse
             {
                 Width  = special ? 6 : 2,
                 Height = special ? 6 : 2,
                 Fill   = new SolidColorBrush(special ? Colors.LightBlue : gradient[(int)(fscores[index] / maxscore * 100)])
             };
             _points.Add(ellipse);
             mainWindow.AddPlayerPoint(ellipse);
         }
     }
 }
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <List <PointPositionsList> > filesPointsPositions = files.Select(file => CsvHelper.ParseFileToPointsPositions(file)).ToList();
            List <List <List <double> > >     filesPointsDeltas    = filesPointsPositions.Select(filePointPositions => CalculateDeltas(filePointPositions)).ToList();

            timeDeltas = filesPointsPositions.Select(filePointPositions => CalculateTimeDeltas(filePointPositions)).ToList();
            List <List <double> > filesResults = filesPointsDeltas.Select((pointsDeltas, i) =>
            {
                currentFileNumber = i;
                return(pointsDeltas.Select(DeltasToResult).ToList());
            }).ToList();

            return(files.Select(file => new NamedIndexedList(file))
                   .Select((fileWithValues, fileIndex) =>
            {
                fileWithValues.SetValuesAutoIndexed(filesResults[fileIndex]);
                return fileWithValues;
            }).ToList());
        }
Exemple #10
0
        public override List <NamedIndexedList> ConsumeFiles(string parameters, params string[] files)
        {
            List <List <PointPositionsList> > filesPointsPositions = files.Select(file => CsvHelper.ParseFileToPointsPositions(file)).ToList();

            // here rescale to be relative
            filesPointsPositions = RescaleRelatively(filesPointsPositions);

            List <List <List <double> > > filesPointsDeltas = filesPointsPositions.Select(filePointPositions => CalculateDeltas(filePointPositions)).ToList();
            List <List <double> >         filesResults      = filesPointsDeltas.Select(pointsDeltas => pointsDeltas.Select(DeltasToResult).ToList()).ToList();

            return(files.Select(file => new NamedIndexedList(file))
                   .Select((fileWithValues, fileIndex) =>
            {
                fileWithValues.SetValuesAutoIndexed(filesResults[fileIndex]);
                return fileWithValues;
            }).ToList());
        }
Exemple #11
0
 private void WriteLine(IReadOnlyList <CameraSpacePoint> points)
 {
     CsvHelper.WriteCameraPointsAsCsvLine(file, points);
     mainWindow.SetBufferSize(buffer.Count, this);
 }