Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get the Average with No LINQ code ! Pin
#realJSOP4-May-19 2:41
mve#realJSOP4-May-19 2:41 
AnswerRe: How to get the Average with No LINQ code ! Pin
Richard MacCutchan3-May-19 4:59
mveRichard MacCutchan3-May-19 4:59 
GeneralRe: How to get the Average with No LINQ code ! Pin
Abdalla Ben Omran3-May-19 5:31
Abdalla Ben Omran3-May-19 5:31 
GeneralRe: How to get the Average with No LINQ code ! Pin
Richard MacCutchan3-May-19 5:35
mveRichard MacCutchan3-May-19 5:35 
QuestionHow to read CSV file which the data in File is not clear ! Pin
Abdalla Ben Omran2-May-19 23:12
Abdalla Ben Omran2-May-19 23:12 
AnswerRe: How to read CSV file which the data in File is not clear ! Pin
OriginalGriff2-May-19 23:14
mveOriginalGriff2-May-19 23:14 
AnswerRe: How to read CSV file which the data in File is not clear ! Pin
Richard MacCutchan2-May-19 23:32
mveRichard MacCutchan2-May-19 23:32 
AnswerRe: How to read CSV file which the data in File is not clear ! Pin
BillWoodruff3-May-19 2:42
professionalBillWoodruff3-May-19 2:42 
If the data is corrupt, you cannot use it ... unless: you can see a pattern in what is wrong, and work around that.

Your definition of thee field names omits what are obviously two values representing years.

Each line of your data appears to contain 2 hyphens, and 13 commas, so if you split it like this:
char[] splitChars = new char[] { '-', ',' };

string[] splitLine =
    "2014-7-1,76,66,86,66,85,48,97,1885,1970,0.13,0.16,5.09".Split(splitChars,
        StringSplitOptions.RemoveEmptyEntries);

if (splitLine.Length != 15)
{
    // handle bad line
}
Of course that's a crude method. I would construct a validation method that would parse the string/line into (first) a DateTime, then, into integers (for the years), and doubles (for temps). Something like:

public bool TryValidate(string line, out ValidData data)
{
data = default(data);
// process
// return true or false
}

public class ValidData
{
public DateTime DTime;
// ...
// construct
}
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

AnswerRe: How to read CSV file which the data in File is not clear ! Pin
Gerry Schmitz3-May-19 3:52
mveGerry Schmitz3-May-19 3:52 
AnswerRe: How to read CSV file which the data in File is not clear ! Pin
#realJSOP4-May-19 4:49
mve#realJSOP4-May-19 4:49 
QuestionLiterally my first "program", and I'm trying to break it down. Pin
Member 143531442-May-19 13:36
Member 143531442-May-19 13:36 
AnswerRe: Literally my first "program", and I'm trying to break it down. Pin
Member 143531442-May-19 13:44
Member 143531442-May-19 13:44 
GeneralRe: Literally my first "program", and I'm trying to break it down. Pin
Gerry Schmitz2-May-19 13:57
mveGerry Schmitz2-May-19 13:57 
AnswerRe: Literally my first "program", and I'm trying to break it down. Pin
OriginalGriff2-May-19 21:28
mveOriginalGriff2-May-19 21:28 
QuestionSoftware/Tool for Form Designing to be user on cross platform Pin
Singh Anita2-May-19 3:23
Singh Anita2-May-19 3:23 
AnswerRe: Software/Tool for Form Designing to be user on cross platform Pin
Richard MacCutchan2-May-19 3:36
mveRichard MacCutchan2-May-19 3:36 
QuestionDéveloppement général Pin
Member 1434980630-Apr-19 5:52
Member 1434980630-Apr-19 5:52 
AnswerRe: Développement général Pin
OriginalGriff30-Apr-19 6:32
mveOriginalGriff30-Apr-19 6:32 
AnswerMODBUS RTU Pin
Luc Pattyn30-Apr-19 9:01
sitebuilderLuc Pattyn30-Apr-19 9:01 
AnswerRe: Développement général Pin
Gerry Schmitz30-Apr-19 20:56
mveGerry Schmitz30-Apr-19 20:56 
QuestionNewbie: if/else Pin
Member 1434938430-Apr-19 2:38
Member 1434938430-Apr-19 2:38 
AnswerRe: Newbie: if/else Pin
OriginalGriff30-Apr-19 3:10
mveOriginalGriff30-Apr-19 3:10 
GeneralRe: Newbie: if/else Pin
Member 1434938430-Apr-19 4:23
Member 1434938430-Apr-19 4:23 
GeneralRe: Newbie: if/else Pin
OriginalGriff30-Apr-19 4:30
mveOriginalGriff30-Apr-19 4:30 
GeneralRe: Newbie: if/else Pin
Richard MacCutchan30-Apr-19 5:47
mveRichard MacCutchan30-Apr-19 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.