viceroypenguin / DBSCAN

Implementation of the DBSCAN clustering algorithm
MIT License
29 stars 7 forks source link

No members are mapped for type 'Dbscan.IPointData' #27

Closed narayanvaze closed 1 year ago

narayanvaze commented 1 year ago

using Dbscan; using System.Globalization; using CsvHelper; using (var reader = new StreamReader(@"D:\dev-nrv\random-2d-points.csv")) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { var records = csv.GetRecords<IPointData>();

//following line of code gives "CsvHelper.ReaderException HResult=0x80131500 Message=No members are mapped for type //'Dbscan.IPointData'. IReader state: ColumnCount: 0 CurrentIndex: -1 HeaderRecord: ["x","y"]" error_

var clusters = Dbscan.Dbscan.CalculateClusters(records.ToList(), epsilon: 2.0, minimumPointsPerCluster: 3); } My csv data has two columns 'x' and 'y' with datatype double and seperation character is a comma - ','. Is this an issue with Dbscan package or the CsvHelper?

viceroypenguin commented 1 year ago

Neither. Your header data should be in columns X and Y, not x and y (notice the case-difference). Per the CsvHelper docs, the case must match by default. Alternatively, you can pass in a configuration that will allow matching headers to lower-case of property names, or you can use a ClassMap.

Hope this helps!

narayanvaze commented 1 year ago

Thank you for taking some time out for my query. Actually, I checked that my headers are indeed X and Y and not x and y. I'll go through CsvHelper docs and ClassMap and let you know here if I find anything helpfull.

viceroypenguin commented 1 year ago

Glad I was able to help. Closing for lack of activity. Please feel free to reopen if you have any further questions. Thanks!