Put values from a text file in a matrix.
-
I have a textfile with values separated by tabs. It looks like below (only difference is that there can be many more columns and rows): Voltage Temperature 6.41000 4.76610 3.41000 4.76366 6.41000 4.83936 6.41000 5.00298 6.41000 5.01763 6.41000 5.05670 Can anyone suggest a method to read from the text file and put the values in a matrix??? The problem is that nothing is known from the beginning. I was thinking of using ReadLine() and then break up the line in smaller pieces (one piece per value) but I find it hard to do because of all the unknown parameters (number of characters in each value, number of columns in the text file etc.) Thanks!
-
I have a textfile with values separated by tabs. It looks like below (only difference is that there can be many more columns and rows): Voltage Temperature 6.41000 4.76610 3.41000 4.76366 6.41000 4.83936 6.41000 5.00298 6.41000 5.01763 6.41000 5.05670 Can anyone suggest a method to read from the text file and put the values in a matrix??? The problem is that nothing is known from the beginning. I was thinking of using ReadLine() and then break up the line in smaller pieces (one piece per value) but I find it hard to do because of all the unknown parameters (number of characters in each value, number of columns in the text file etc.) Thanks!
If you know the character that will separate columns, you can use ReadLine() method and than use Split() method of string class. There are several libraries at codeproject that can help you in reading csv files.
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion