How Convert to Double from string ??

patrick

Well-known member
Joined
Dec 5, 2021
Messages
249
Programming Experience
1-3
In IEnumerable and LINQ,

How Convert to Double from string ??


I want to return the values of the SCROE column as a list of double types.
C#:
using System;
using Sylvan.Data;
using Sylvan.Data.Csv;
using System.Collections.Generic;
using System.Linq;

using var csvReader = CsvDataReader.Create("data.csv");
IEnumerable<Pepole> Pepoles = csvReader.GetRecords<Pepole>();
IEnumerable<Pepole> GroupbyedPepoles = Pepoles.GroupBy(r => r.subject); //<=Is the Groupby syntax correct?

List<Pepole> DoubleTyped = GroupbyedPepoles.??????(n=>n.scroe).ToList(); //<=I want to import Scroe Column as double type.

class Pepole
{
    public string ID {get; set;}
    public string NAME {get; set;}
    public string SCHOOL {get; set;}
    public string SUBJECT {get; set;}
    public string SCROE {get; set;}
}

q4.png
 
Last edited:
Look at your old posts. You used to use convert strings to integers. You would do the same for doubles. Oh wait! You keep deleting your old posts. I guess you can't look. Too bad.
 
Look at your old posts. You used to use convert strings to integers. You would do the same for doubles. Oh wait! You keep deleting your old posts. I guess you can't look. Too bad.
The Score Column in the csv file is a string.
But I don't know that Scroe Column is returned as double when returning as IEnumerable.
 
Did you read the Sylvan documentation? Specifically about about it automatic data mapper that you are using? If yes, what did it say about data conversions? If not, you better go read the documentation and then try some experiments.
 
Did you read the Sylvan documentation? Specifically about about it automatic data mapper that you are using? If yes, what did it say about data conversions? If not, you better go read the documentation and then try some experiments.

C#:
using System;
using Sylvan.Data;
using Sylvan.Data.Csv;
using System.Collections.Generic;
using System.Linq;

using var csvReader = CsvDataReader.Create("data.csv");
IEnumerable<Pepole> Pepoles = csvReader.GetRecords<Pepole>();

List <Pepole> GroupbyedPepoles = Pepoles.GroupBy(r => r.subject).ToList(); //<=Is the Groupby syntax correct?
List<Pepole> DoubleTyped = GroupbyedPepoles.??????(n=>n.scroe).ToList(); //<=I want to import Scroe Column as double type.

class Pepole
{
    public string ID {get; set;}
    public string NAME {get; set;}
    public string SCHOOL {get; set;}
    public string SUBJECT {get; set;}
    public string SCROE {get; set;}
}

Changed the type to a LINQ list.
How to In LINQ List, Groupby, Convert to double from string.
 
As I was implying, read the documentation. You can let Sylvan do thr work for you while it is loading the data instead of you doing the work after Sylvan has already loaded the data.
 
Well, I guess that answers the question whether you have read the documentation or not if you are asking where to find the documentation.
 
Back
Top Bottom