Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
2.80/5 (3 votes)
See more:

I'm completely new to programming and I've been given a task to do. I've had a look online and I've put together some code but I'm not sure if I'm going in the right direction. Do you mind having a look at it and letting me know?

This is what I want my program to do when it is complete.

****To import vital sign data as illustrated above into the memory from a text file.
Note: The location of the file should be specified by a string path; any appropriate data structures can be
used to hold the data in the memory.
****To associate flexible timestamps with each group of data that is imported.
Note: A simulated diagnostic session always starts from 0 second, with a configurable sampling interval (SI)
afterwards. For instance, if the SI was set to 5 seconds, then the first group of data would be collected at 0
second, the second group of data at 5 second, the third group of data at 10 second, and so on.
****To return the most recent group of data given a particular time within a simulated diagnostic session.
****Note: The length of a simulated diagnostic session can be determined by the total number of data imported
from the file and the sampling interval. For instance, if 200 groups of data were imported with SI = 5, the
length of the simulated session would be (200-1)*5 = 995 seconds. In this case, the Patient Simulator should be able to return the most recent group of data at any second within the [0, 995] time window.

And this is the code I currently have;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Patient_Simulator
    public partial class Form1 : Form
        public Form1()
         string Data = string.Empty;
        private void Data_Load(object sender, 
            EventArgs e)

        private void btnData_Click(object sender, EventArgs e)
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "Select Data File:";
            DialogResult fd = fbd.ShowDialog();
            if (fd == DialogResult.OK)
                lblData.Text = Data = fbd.SelectedPath;
                lblData.Text = Data = "";

            if (!string.IsNullOrEmpty(Data))
        private void loadData = (string Data)
        string[] photo = Directory.GetFiles(Data, "*.txt");

Could someone point me in the right direction? That would be awesome.
Sergey Alexandrovich Kryukov 5-Feb-14 19:06pm    
I cannot understand anything from your description. What is the goal of all that? Simulation of what? Why? How is the code shown related to description of the problem? What's the problem? And so on...

There's nothing wrong about being at the "beginning" in any technical adventure; to my knowledge everyone begins there :) ... in fact, it may be the opportunity to learn more quickly than at any other time.

I suggest you approach your task of creating an application that parses a file containing Patient vital-sign data by using what's often referred to in computer science as the "divide-and-conquer" approach:

1. make an outline that includes:

a. your goals for the application

b. your notes on, and analysis of, the structure of the data.

c. the required formats for any output from your application (to screen, to printer, etc.).

d. ideas, sketches, requirements for, the user interface

Then, for each goal, develop a list of tasks necessary to reach that goal. Ideally, a task definition should lead to the design of the discrete module of code whose inputs are defined, whose required transformation of the input data is defined, and whose output is defined.

Ideas for some of the required modules may "jump out at you:" it's obvious you are going to need to have a way for the user to select a file, or files. It's obvious that when you have the file, or list of files, you want to analyze, you are going to need to open them and parse them.


1. module 1: select files

2. module 2: parse files

Clearly, parsing the file(s) is going to be shaped/constrained by the requirements for future analysis of the data. In this case, a constraint is that you must parse the data into some form where you can sample it, and present the data, based on a specified interval in seconds.

So, you want to transform the data into internal representations (instances of Classes, or Lists, or whatever) once so that repeated sampling does not incur a high cost of re-analyzing the data.

I can't quite tell from this: "To associate flexible timestamps with each group of data that is imported," if the time/date information you are going to use is based on the file's time-stamp information, or if you are going to create this yourself, on-the-fly, in some way.

To give you more specific advice, I think anyone assisting you here would need to know more about the format of the vital-sign data, and what "timestamp" means in this context.
Share this answer
No, I don't think you are going in the right direction, or at least, you haven't got there yet.
The code you show is concerned only with the trivial part of the task: finding the file containing your simulation data. That's the easy bit, and you can ignore that for the moment and hard-code the file path, and hand the hardcoded path through to a LoadFile method:
myData = LoadFile(@"D:\Temp\MySimulationData.txt");

The complicated part starts when you load the file: and we can't give you specific answers here because we don't have access to the file, or to a description of what it contains.

So, you need to start by looking at the file (and at any supporting info your tutor gave you describing the file content) and begin by identifying the information in each "record". We know it will contain a timestamp, but I don't know what other data it contains, or what format the timestamp takes - so you need to isolate that info.

Then, create a class which contains the information for a single row, and start reading the rows and creating instances of the class. We can;t help you do that yet, because we don't know what data it is, or how it is stored - so you need to sit down and think about it for a while and work some of this stuff out!

You can then look at reading the file a row at a time, and creating the necessary instances, before returning them from your LoadFile method in a collection for some sort.
Share this answer
Before starting to think about the concrete program, you must understand the problem domain first.

The description you give is only a snippet of your whole assignment, it seems.
E.g. several terms are unclear:
a) what are "vital sign" data?
b) whati meant by "as shown above"?
c) what are "group of data"?
d) what is a "diagnostic session"?
e) what is a "patient simulator"?
z) how are these terms interrelated?

Draw on a sheet of paper the whole system:

  • what components are involved (simulator, PC, Data exchange, programs that run on each device, etc.)
  • write some use cases how actions are triggered and what the output is from such triggers
  • draw the sequence of actions that happened with such a trigger of a use case
  • ...

Identify what your task is in that whole system:

  • write a program to fire up a Dialog window that asks the user to enter some file path to process

    • the file consists of one or more diagnostics session data(?)
    • one diagnositcs data consists of groups of data(?)
    • a group of data consists of a sequence of data samples(?)
    • a data sample represents a time slice of the diagnostics session(?)
    • the output of running the program is ...?

    Now you are ready to think about drafting a concept on how you want to process the data.
    The Dialog is what you show in you sample code (this is the zero-effort task).
    now you must add the real function to the program:

    • trigger reading the file

      • reading means convert the (text?) content of the file into meaningful information chuncks (this is called parsing)
      • depending on the actual file format, this parsing may be from very simple to rather elaborate
      • design a data structure that suits your needs, e.g. analogous to the items identified above:
        - a list of diagnostics sessions instances
          - a dignostics session class consists of a list of data groups
            - a data group class consists of a sequence of data samples
              - a data sample class consists of ...
      • the parser now must convert the text from the file into such data structures
    • process the data - not clear from your question
    • write the output - not clear from your question

      • to a database?
      • to the User Interface?
      • to some file?
      • filtered?
      • sorted?
      • ...?

    Once all this above is clarified, you may start to think about programming, but first. what is your eco system you work on:
    - What is your development environment (PC, VS2010, C#, ...)?
    - What is the productive environment for the completed and shipped program (Windows PC, collaboration with program X, Y, Z, ...)?

    If you reached this point, get acquainted with the development environment and the language you want to implement the program (C# in this case).

    Document your analysis.

    Implement the data classes.
    Implement the parser.
    Test the parser and the storage of the data in the data classes.
    Document this part.

    Implement the data processing functions.
    Test these functions.
    Document this part.

    Implement the the data output.
    Test it.
    Document this part.

    Integrate all into the program skeleton from your question.
    Test it.
    Document this part.

    Document your results.
    Provide user documentation.
    Ship it.

    Share this answer
    Please see my comments to the question — nothing is clear.

    Maybe you can sort it out by yourself? The current time is taken this way:[^],[^],
    see also[^].

    The time stamps related to a file can be taken from a file by the file name using the class System.IO.File:[^],[^],[^],[^],[^],[^].

    That's all you may need. Honestly, not many will have patience to dig into your incomplete and unclear description, but, if you still have questions, please ask, but try to be much more descriptive, logical and consistence. Don't forget to explain the ultimate goals, what did you try to achieve, what kind of help you expect to get, and other key items.

    Share this answer

    This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900