Hi guys,
I am pulling my hair out trying to find a FAST method for reading text data from a text file with C#. In C, there was fscanf, but I cannot find a corresponding function built into C#.
My data is a tab-separated text file with 5 columns (see below for exactly what it looks like). The data is all float, and all in 5 columns.
10.3 0 67.2 29.7 12.8
3.7 3.0 56.4 23.3 34.2
(the 5 columns continue downwards for 20mb of data)
**Here the data also has \r and \n (carriage returns and newline characters), but I can easily remove those, or keep them in, whichever's best...
Here's what I have done so far:
StreamReader object to read text file into string.
String.Split to break text file's data columns apart (they are tab-delimited).
Foreach operation in order to interate thru each string and convert to Single float data type.
Now that I have the tab-delimited floats, I would like to assign each column's data into a different float array, but I cannot find a quick way to do this...?
Any advice?
Thanks in advance,
-b
Remember, SPEED is the issue here, since my text files are BIG (~20mb). I tried to use Regex.Matches to match the data to a pattern, but it is WAY too slow and eats tons of RAM (in my hands, anyway
).
PS - Anyone who posts "I don't see what reading text files has to do with trading" can enjoy a pre-emptive "piss off" from me.
I am pulling my hair out trying to find a FAST method for reading text data from a text file with C#. In C, there was fscanf, but I cannot find a corresponding function built into C#.
My data is a tab-separated text file with 5 columns (see below for exactly what it looks like). The data is all float, and all in 5 columns.
10.3 0 67.2 29.7 12.8
3.7 3.0 56.4 23.3 34.2
(the 5 columns continue downwards for 20mb of data)
**Here the data also has \r and \n (carriage returns and newline characters), but I can easily remove those, or keep them in, whichever's best...
Here's what I have done so far:
StreamReader object to read text file into string.
String.Split to break text file's data columns apart (they are tab-delimited).
Foreach operation in order to interate thru each string and convert to Single float data type.
Now that I have the tab-delimited floats, I would like to assign each column's data into a different float array, but I cannot find a quick way to do this...?
Any advice?
Thanks in advance,
-b
Remember, SPEED is the issue here, since my text files are BIG (~20mb). I tried to use Regex.Matches to match the data to a pattern, but it is WAY too slow and eats tons of RAM (in my hands, anyway
). PS - Anyone who posts "I don't see what reading text files has to do with trading" can enjoy a pre-emptive "piss off" from me.
