Read the data from text file and plot in visual basic-VBForums
Results 1 to 2 of 2

Thread: Read the data from text file and plot in visual basic

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    16

    Read the data from text file and plot in visual basic

    I have a dataset in the following format :

    Code:
    Station1	98.0	76.5
    4	8/19/2010 00:10 AM
    	0	1	2	3	
    	38.6	38.5	38.3	38	
    5	8/19/2010 10:33 AM
    	0	1	2	3	4	
    	39.7	39.7	39.6	39.6	39.5	
    6	9/15/2010 8:30 AM
    	0	1	2	3	4	5
    	37.4	37.5	37.4	37.4	37.3	37.2
    5	9/15/2010 12:15 PM
    	0	1	2	3	4	
    	40.3	40.3	40.3	40.3	40.2
    5	9/15/2010 18:25 PM
    	0	1	2	3	4	
    	40.9	40.9	40.9	40.9	40.9
    The above data is temperature profile. The first line shows the station name and coordinates of that station.

    I am concerned about second line. I have data for 5 time periods in the above data.

    The first line after the time is the depth at different heights (i.e from 0 to upto 5) and the second line is corresponding temperature.

    I want to read the data such that I want to store the date and heights and temperature for each data set. So, basically I want to be able to store these data for each time.

    Name:  temp_profile.png
Views: 715
Size:  141.6 KB

    Later I want to use the stored data to plot profiles. On the legend I want the time and the x-axis would be temperature and my y-axis would be temperature. I want to use a numeric up down button to change from one time to another in the plot window.


    Btw, I am a beginner in VB.net.
    Thank you for any advice.

    Regards,
    Jdbaba
    Last edited by jdbaba; Mar 4th, 2014 at 10:32 PM.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,291

    Re: Read the data from text file and plot in visual basic

    You have told us what you want. The next phase would be telling us what you've done so far. We can give you ideas, code examples, corrections... but I doubt that anyone would help you write the whole application.
    The 1st thing you'd need is to parse the text file. If the format of that text file is consistent, parsing it isn't too bad. You can use a streamreader object and read each line, keeping track of what line number it is so that you can tell if it's the line with date/time, heights or temperatures... You then split that line to get the data points. Save it to a datatable. The datatable, as I'd imagine, would have 6 columns: [Date], [H0], [H1], [H2], [H3], [H4] and [H5]. Column [Date] stores the date/time for that time period and columns H0-H5 store the temperatures.
    For graphing, you can use the Chart Controls if you target .Net 3.5 or newer. If your target framework is older, try ZedGraph.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.