How do I create a graph using specific columns from a text file in c#?

时间:2017-06-09 12:45:01

标签: c# file text graph tabs

I am trying to create a program where you can browse for a text file with a specific format and grab certain columns from it. Those columns will then be graphed inside of a tab, however, there is multiple data tables per file and I need to be able to create tabs according to the number of graphs needed. The number isn't always the same per file. The headings for each graph needed are similar so I was hoping to find a way for the program to find the specific name and grab the data below it.

This is all I have so far. I don't know how to grab the specific data to then be able to graph it in tabs.

using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApp1
{

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

    //allows user to browse for a textfile and view the contents in a text box
        private void folderPath_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile1 = new OpenFileDialog();
            openFile1.Filter = "Text Files|*.txt";

            if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                richTextBox1.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
            }

        }
    }
}

So far all this program does is show the information from the text file in a text box

The data will look something like
A1 B1 C1 D1 E1 F1
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30

A2 B2 C2 D2 E2 F2
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30

... and so on but I need to graph column C(1,2) vs. D(1,2) If anyone can help, I'd really appreciate it!!

0 个答案:

没有答案