Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board

Go Back   Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board > Thoroughbred Horse Racing Discussion > Handicapping Software > HandiFast Handicapping Software


Reply
 
Thread Tools Rate Thread
Old 08-01-2013, 04:26 PM   #1
douglasw32
douglasw32
 
douglasw32's Avatar
 
Join Date: Dec 2003
Location: Horseheads, NY
Posts: 1,630
C# code for pullinf the .drf CSV file into an array

In VB6 I would do a loop until end of file and assign into an array
Then pull it by number to crunch something.

i.e.

open for input drf
Loop x until eof
the whole file loops into drf(x)
Then I process using drf(52) that gives me the 52nd comma field.

That is not the exact code but I hope it makes my point.

How do I do the same thing in C# ?
__________________
My Twitter
FaceBook
douglasw32 is offline   Reply With Quote Reply
Old 08-01-2013, 04:30 PM   #2
DeltaLover
Registered user
 
DeltaLover's Avatar
 
Join Date: Oct 2008
Location: FALIRIKON DELTA
Posts: 4,439
Try the following:

(1) Open the file using StreamReader

(2) Write a while statement reading the next line from the reader until you receive null

(3) Tokenize each line using the string.Split method providing comma (,) as the delimeter
__________________
whereof one cannot speak thereof one must be silent
Ludwig Wittgenstein
DeltaLover is offline   Reply With Quote Reply
Old 08-01-2013, 08:51 PM   #3
Augenj
Top Horse Analytics
 
Augenj's Avatar
 
Join Date: Mar 2013
Location: Las Vegas, NV
Posts: 12,303
Quote:
Originally Posted by douglasw32
In VB6 I would do a loop until end of file and assign into an array
Then pull it by number to crunch something.

i.e.

open for input drf
Loop x until eof
the whole file loops into drf(x)
Then I process using drf(52) that gives me the 52nd comma field.

That is not the exact code but I hope it makes my point.

How do I do the same thing in C# ?
Use VB.Net
Augenj is online now   Reply With Quote Reply
Old 10-19-2013, 10:48 PM   #4
headhawg
crusty old guy
 
headhawg's Avatar
 
Join Date: Aug 2003
Location: Snarkytown USA
Posts: 3,919
Here's a function that might work. I'm messing around with .Net and both VB and C#. My nephew wrote this routine.
static string[] Split(string expression, string delimiter,
string qualifier, bool ignoreCase)
{
bool _QualifierState = false;
int _StartIndex = 0;
System.Collections.ArrayList _Values = new System.Collections.ArrayList();

for (int _CharIndex = 0; _CharIndex < expression.Length ; _CharIndex++)
{
if ((qualifier != null) & (string.Compare(expression.Substring(_CharIndex, qualifier.Length), qualifier, ignoreCase) == 0))
{
_QualifierState = !(_QualifierState);
}
else if (!(_QualifierState) & (delimiter != null) & (string.Compare(expression.Substring(_CharIndex, delimiter.Length), delimiter, ignoreCase) == 0))
{
_Values.Add(expression.Substring(_StartIndex, _CharIndex - _StartIndex));
_StartIndex = _CharIndex + 1;
}
}

if (_StartIndex <= expression.Length)
_Values.Add(expression.Substring(_StartIndex, expression.Length - _StartIndex));

string[] _returnValues = new string[_Values.Count];
_Values.CopyTo(_returnValues);
return _returnValues;
}

Maybe the code will help you out. Sorry about the formatting.

headhawg is offline   Reply With Quote Reply
Reply





Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

» Advertisement
» Current Polls
Wh deserves to be the favorite? (last 4 figures)
Powered by vBadvanced CMPS v3.2.3

All times are GMT -4. The time now is 09:39 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 1999 - 2023 -- PaceAdvantage.Com -- All Rights Reserved
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program
designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.