Click here to Skip to main content
15,935,728 members
Home / Discussions / C#
   

C#

 
AnswerRe: Read comma delimited .txt file with large number of data - do search in column A Pin
BillWoodruff18-Dec-13 3:32
professionalBillWoodruff18-Dec-13 3:32 
GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
Manfred Rudolf Bihy18-Dec-13 3:53
professionalManfred Rudolf Bihy18-Dec-13 3:53 
GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
BillWoodruff18-Dec-13 4:30
professionalBillWoodruff18-Dec-13 4:30 
GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
lordoftrades18-Dec-13 4:12
lordoftrades18-Dec-13 4:12 
AnswerRe: Read comma delimited .txt file with large number of data - do search in column A Pin
jschell18-Dec-13 9:09
jschell18-Dec-13 9:09 
GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
lordoftrades18-Dec-13 9:59
lordoftrades18-Dec-13 9:59 
GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
jschell19-Dec-13 14:10
jschell19-Dec-13 14:10 
AnswerRe: Read comma delimited .txt file with large number of data - do search in column A Pin
BillWoodruff18-Dec-13 11:18
professionalBillWoodruff18-Dec-13 11:18 
Now that your specification is clear(er), I can suggest to you some architectural features of the C# code you might employ. I won't "flesh that out," since if I did I think I'd be writing commercial code for free, and that's not what CP is for. Also, I am confident that if you can code this in VBA, you can code it in C# !

Given your possible 400 lines of distilled analysis, I'd see no problem reading/parsing your data into a generic List<struct>. The struct and the List<struct> might look like this:
C#
private struct DayTrade
{
    public DateTime DateOpen;
    public DateTime StartTime;
    public double OpenPrice;
    public double StartPrice;
    public double HighPrice;
    public double LowPrice;
    public int SharesTraded;
}

private List<DayTrade> DayTradeList = new List<DayTrade>();
I would create the generic List, and then serialize/deserialize it to save/access the data. For serialization to XML, or binary, you could evaluate .NET's built-in facilities in System.Xml and System.Runtime.Serialization; or, you could look into using the MS DataContractSerializer Class, or you could check out Mehdi Gholam's excellent fastJSON and fastBinaryJSON libraries published here on CodeProject.

To get ready to parse the data into structs, I'd define these variables:
C#
// for splitting the data into lines
private char[] splitLineBreak = Environment.NewLine.ToCharArray();
// for splitting the data by comma
private char[] splitComma = new char[] {','};

// for use in parsing
private string currentLine;
private List<string> lineList = new List<string>();
private List<string> splitLineList = new List<string>();
Steps in parsing would be:

1. split the data into lines:
// I prefer to work with Lists
lineList = data.Split(splitLineBreak, StringSplitOptions.RemoveEmptyEntries).ToList<string>();
2. in the parsing loop:
XML
for (int i = 0; i < lineList.Count; i++)
{
    // create a new struct
    DayTrade OneDaysTrade = new DayTrade();

    // get the current line
    currentLine = lineList[i];

    // split the current line by comma
    splitLineList = currentLine.Split(splitComma, StringSplitOptions.RemoveEmptyEntries).ToList<string>();

// somewhere in your parsing algorithm you are going to be using code like this:
   // OneDaysTrade.DateOpen = Convert.ToDateTime(splitLineList[0]);
   // OneDaysTrade.StartTime = Convert.ToDateTime(splitLineList[1]);
   // OneDaysTrade.OpenPrice = Convert.ToDouble(splitLineList[2]);
   //
   // and so forth

   // finally you are going to add the fleshed out struct to your List
    DayTradeList.Add(OneDaysTrade);
}
Of course your parsing code will have to handle the transition in reading the data from one day to the next, but I am sure you are already aware of how to do that, and how to create any intermediate variables required. And I'm sure you know how to compare each current day's high and low, and save the highest high, and lowest low, etc.
If you seek to aid everyone that suffers in the galaxy, you will only weaken yourself … and weaken them. It is the internal struggles, when fought and won on their own, that yield the strongest rewards… If you care for others, then dispense with pity and sacrifice and recognize the value in letting them fight their own battles." Darth Traya

GeneralRe: Read comma delimited .txt file with large number of data - do search in column A Pin
lordoftrades18-Dec-13 11:22
lordoftrades18-Dec-13 11:22 
QuestionZoom in and Zoom out feature in a picturebox Pin
alfie.max1518-Dec-13 0:00
alfie.max1518-Dec-13 0:00 
AnswerRe: Zoom in and Zoom out feature in a picturebox Pin
Richard MacCutchan18-Dec-13 1:22
mveRichard MacCutchan18-Dec-13 1:22 
AnswerRe: Zoom in and Zoom out feature in a picturebox Pin
JV999918-Dec-13 1:22
professionalJV999918-Dec-13 1:22 
AnswerRe: Zoom in and Zoom out feature in a picturebox Pin
Snehasish_Nandy18-Dec-13 1:41
professionalSnehasish_Nandy18-Dec-13 1:41 
AnswerRe: Zoom in and Zoom out feature in a picturebox Pin
BillWoodruff18-Dec-13 3:25
professionalBillWoodruff18-Dec-13 3:25 
QuestionStuck on delegates / events Pin
Member 1036998617-Dec-13 6:19
Member 1036998617-Dec-13 6:19 
AnswerRe: Stuck on delegates / events Pin
Pete O'Hanlon17-Dec-13 6:38
mvePete O'Hanlon17-Dec-13 6:38 
GeneralRe: Stuck on delegates / events Pin
jxfdasilva17-Dec-13 6:54
jxfdasilva17-Dec-13 6:54 
GeneralRe: Stuck on delegates / events Pin
Pete O'Hanlon17-Dec-13 6:59
mvePete O'Hanlon17-Dec-13 6:59 
GeneralRe: Stuck on delegates / events Pin
jxfdasilva17-Dec-13 7:07
jxfdasilva17-Dec-13 7:07 
GeneralRe: Stuck on delegates / events Pin
Pete O'Hanlon17-Dec-13 7:33
mvePete O'Hanlon17-Dec-13 7:33 
GeneralRe: Stuck on delegates / events Pin
jxfdasilva17-Dec-13 7:42
jxfdasilva17-Dec-13 7:42 
GeneralRe: Stuck on delegates / events Pin
Pete O'Hanlon17-Dec-13 7:50
mvePete O'Hanlon17-Dec-13 7:50 
GeneralRe: Stuck on delegates / events Pin
Pete O'Hanlon17-Dec-13 7:54
mvePete O'Hanlon17-Dec-13 7:54 
GeneralRe: Stuck on delegates / events Pin
Richard Deeming17-Dec-13 8:28
mveRichard Deeming17-Dec-13 8:28 
GeneralRe: Stuck on delegates / events Pin
jxfdasilva17-Dec-13 8:28
jxfdasilva17-Dec-13 8:28 

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.