コード例 #1
0
        public static void ReadAll_LumenWorks(DelimitedRecordReaderBenchmarkArguments args)
        {
            using (var reader = new LW.CsvReader(new StreamReader(args.Path, args.Encoding, true, args.BufferSize), false, LW.CsvReader.DefaultDelimiter, LW.CsvReader.DefaultQuote, LW.CsvReader.DefaultEscape, LW.CsvReader.DefaultComment, args.TrimWhiteSpaces ? LW.ValueTrimmingOptions.All : LW.ValueTrimmingOptions.None, args.BufferSize))
            {
                reader.SkipEmptyLines = args.SkipEmptyLines;

                string s;

                if (args.FieldIndex < 0)
                {
                    while (reader.ReadNextRecord())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            s = reader[i];
                        }
                    }
                }
                else
                {
                    while (reader.ReadNextRecord())
                    {
                        for (int i = 0; i < args.FieldIndex + 1; i++)
                        {
                            s = reader[i];
                        }
                    }
                }
            }
        }
コード例 #2
0
		public static void ReadAll_LumenWorks(DelimitedRecordReaderBenchmarkArguments args)
		{
			using (var reader = new LW.CsvReader(new StreamReader(args.Path, args.Encoding, true, args.BufferSize), false, LW.CsvReader.DefaultDelimiter, LW.CsvReader.DefaultQuote, LW.CsvReader.DefaultEscape, LW.CsvReader.DefaultComment, args.TrimWhiteSpaces ? LW.ValueTrimmingOptions.All : LW.ValueTrimmingOptions.None, args.BufferSize))
			{
				reader.SkipEmptyLines = args.SkipEmptyLines;

				string s;

				if (args.FieldIndex < 0)
				{
					while (reader.ReadNextRecord())
					{
						for (int i = 0; i < reader.FieldCount; i++)
							s = reader[i];
					}
				}
				else
				{
					while (reader.ReadNextRecord())
					{
						for (int i = 0; i < args.FieldIndex + 1; i++)
							s = reader[i];
					}
				}
			}
		}
コード例 #3
0
        private void loadDatabase()
        {
            //read movies.csv
            using (var fs = File.OpenRead(@"db/movies.csv"))
                using (var reader = new StreamReader(fs))
                {
                    using (var csvReader = new LumenWorks.Framework.IO.Csv.CsvReader(reader, true))
                    {
                        while (csvReader.ReadNextRecord())
                        {
                            //the first line is the headers line (movieID,Title,genres)
                            Movie movie = new Movie(csvReader[0]);
                            movie.MovieTitle = csvReader[1];
                            movie.Genres     = Movie.splitToGenres(csvReader[2]);
                            moviesDictionary[csvReader[0]] = movie;
                            moviesToGrab.Enqueue(movie);
                        }
                    }
                }

            using (var fs = File.OpenRead(@"db/links.csv"))
                using (var reader = new StreamReader(fs))
                {
                    using (var csvReader = new LumenWorks.Framework.IO.Csv.CsvReader(reader, true))
                    {
                        while (csvReader.ReadNextRecord())
                        {
                            if (moviesDictionary.ContainsKey(csvReader[0]))
                            {
                                moviesDictionary[csvReader[0]].UrlLink = "tt" + csvReader[1]; //add the IMDB link
                            }
                        }
                    }
                }
        }
コード例 #4
0
 public Nullable <BusStop> getStopInfo(int id)
 {
     using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"), true)) {
         while (csv.ReadNextRecord())
         {
             if (int.Parse(csv["stop_id"]) == id)
             {
                 return(new BusStop(csv["stop_name"], id, new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]))));
             }
         }
         return(null);
     }
 }
コード例 #5
0
ファイル: BusDB_GTFS.cs プロジェクト: jboolean/RIT-Bus
 //Caution: If radius is too large results will be HUGE!
 //radius in meters
 public IEnumerable<BusStop> getAllBusStops(CLLocation aboutLoc, double radius)
 {
     List<BusStop> stops = new List<BusStop>(30);
     using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"),true)) {
         while (csv.ReadNextRecord()){
             CLLocation loc = new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]));
             if (loc.DistanceFrom(aboutLoc)<=radius)
                 stops.Add(new BusStop(csv["stop_name"],int.Parse(csv["stop_id"]), loc));
             loc.Dispose();
         }
         return stops;
     }
 }
コード例 #6
0
        //Caution: If radius is too large results will be HUGE!
        //radius in meters
        public IEnumerable <BusStop> getAllBusStops(CLLocation aboutLoc, double radius)
        {
            List <BusStop> stops = new List <BusStop>(30);

            using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"), true)) {
                while (csv.ReadNextRecord())
                {
                    CLLocation loc = new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]));
                    if (loc.DistanceFrom(aboutLoc) <= radius)
                    {
                        stops.Add(new BusStop(csv["stop_name"], int.Parse(csv["stop_id"]), loc));
                    }
                    loc.Dispose();
                }
                return(stops);
            }
        }
コード例 #7
0
        private void CountActivities(CsvReader csv)
        {
            int fieldCount = csv.FieldCount;

            string[] headers = csv.GetFieldHeaders();
            while (csv.ReadNextRecord())
            {
                string activityName = csv[(int)Fields.ActivityName];
                if (_activityCount.ContainsKey(activityName))
                {
                    _activityCount[activityName]++;
                }
                else
                {
                    _activityCount.Add(activityName, 1);
                }
            }
        }
コード例 #8
0
        private string SerializeCsv(CsvReader csv)
        {
            string results = "";

            int fieldCount = csv.FieldCount;

            string[] headers = csv.GetFieldHeaders();
            while (csv.ReadNextRecord())
            {
                for (int i = 0; i < fieldCount; i++)
                {
                    results += csv[i] + " ";
                }
                results += "\n";
            }

            return(results);
        }
コード例 #9
0
ファイル: BusDB_GTFS.cs プロジェクト: jboolean/RIT-Bus
 public Nullable<BusStop> getStopInfo(int id)
 {
     using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"),true)) {
         while (csv.ReadNextRecord()){
             if (int.Parse(csv["stop_id"])== id){
                 return new BusStop(csv["stop_name"],id, new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"])));
             }
         }
         return null;
     }
 }