OneStopGate.Com
OnestopGate   OnestopGate
   Friday, May 17, 2024 Login  
OnestopGate
Home | Overview | Syllabus | Tutorials | FAQs | Downloads | Recommended Websites | Advertise | Payments | Contact Us | Forum
OneStopGate

GATE Resources
Gate Articles
Gate Books
Gate Colleges 
Gate Downloads 
Gate Faqs
Gate Jobs
Gate News 
Gate Sample Papers
Training Institutes

GATE Overview
Overview
GATE Eligibility
Structure Of GATE
GATE Coaching Centers
Colleges Providing M.Tech/M.E.
GATE Score
GATE Results
PG with Scholarships
Article On GATE
Admission Process For M.Tech/ MCP-PhD
GATE Topper 2012-13
GATE Forum




GATE 2025 Exclusive
Organizing Institute
Important Dates
How to Apply
Discipline Codes
GATE 2025 Exam Structure

GATE 2025 Syllabus
Aerospace Engg..
Agricultural Engg..
Architecture and Planning
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Geology and Geophysics
Instrumentation Engineering
Life Sciences
Mathematics
Mechanical Engg..
Metallurgical Engg..
Mining Engg..
Physics
Production & Industrial Engg..
Pharmaceutical Sciences
Textile Engineering and Fibre Science

GATE Study Material
Aerospace Engg..
Agricultural Engg..
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Instrumentation Engg..
Life Sciences
Mathematics
Mechanical Engg..
Physics
Pharmaceutical Sciences
Textile Engineering  and Fibre Science

GATE Preparation
GATE Pattern
GATE Tips N Tricks
Compare Evaluation
Sample Papers 
Gate Downloads 
Experts View

CEED 2013
CEED Exams
Eligibility
Application Forms
Important Dates
Contact Address
Examination Centres
CEED Sample Papers

Discuss GATE
GATE Forum
Exam Cities
Contact Details
Bank Details

Miscellaneous
Advertisment
Contact Us


Home » GATE Study Material » Electrical Engineering » Digital Signals and Data Representation » Data Files

Digital Signals and Data Representation

Looking for GATE Preparation Material? Join & Get here now!

** Gate 2013 Question Papers.. ** CEED 2013 Results.. ** Gate 2013 Question Papers With Solutions.. ** GATE 2013 CUT-OFFs.. ** GATE 2013 Results.. **

<<Previous
Data Files

Here are a few things you can do after you have copied the data and gotten it onto the computer clipboard.
  • Start a word processor on your computer and paste the data into the word processor.
  • Start a spreadsheet and paste the data into the spreadsheet.
Putting data on a clipboard and pasting it into an application is one way to get data into a program. However, in some cases you may need to do something else to get the data into a program. Analysis programs like Mathcad and Matlab can also load this data, but each program has a special way of getting the data into the workspace so it can be analyzed.

We need to examine the file contents of the simple file in more detail than we have to this point. Here is what is important.


  • When you type you generate characters. When you type a ""3"" you generate a character that is put into the editor for later storage in the file.
  • Even when you use the ""Enter"" key you are typing a character or two. You are entering a carriage return and/or a new line character, and each has its' own ASCII representation.
  • When you store the data in a file, you are storing characters - the characters that you typed.
Tabs, carriage returns and line feeds and other characters are ASCII characters, and you can write those characters into files from all popular programming languages. Also you can write strings of characters in other contexts. Here are some programming segments that write a string ""TEM"" followed by a carriage return and line feed. In these examples, a function is used to write the string to an instrument to cause it to measure a temperature. In BASIC C3$="TEM"+CHR$(&HD)+CHR$(&HA)
CALL IBWRT(DAU%,C3$) In C/C++ long dau;
ibwrt(dau, "TEM\r\n", 5);
Some special characters are listed below.
ASCII Character Number
Name
BASIC form
C form
9
Tab
CHR$(&H9)
\t
10
LF
CHR$(&HA)
\n
13
CR
CHR$(&HD)
\r

The letters also have a numerical code. That's the first column in the table above. Every character - all 256 possible ASCII characters - correspond to one of the numbers fomr 0 to 255. That numerical correspondence allows us to identify each character with a number.

At this point you have the knowledge you need to understand how data can be stored in files. This isn't the entire story. Storing data as characters is often done, but it is also possible to store data in numerical formats. That's another topic. However, IEEE-488 instruments often transmit data using a character format, and that's something you can learn about in another lesson.


Creating And Using Flat Files in C

C has numerous functions for creation and deletion of files, as well as functions that open your files, write data to them and close them.

In this section we'll give you some functions we have written that allow you to create your own data files in a flat file format. You can embed these functions in programs that read laboratory data, and you can use these functions to create files with lab data that you can open in spreadsheets and analysis programs. With that capability you can then plot and analyze your lab data.

The functions we will give you will be the simplest possible. You can then modify these functions to "personalize""them for your own purposes.

The sequence of operations in a typical program might be the following.

  • Open a data file so that you can write data to it.
  • Write data to the file you have open.
  • Close the data file.
Here's a function that will open a file named DATAFILE.TXT on the A drive. If the file doesn't already exist, fopen creates it automatically. The function, fopen, used here is a standard, ANSI C, function. You can select the text and use Ctrl+C to copy the function if you are in a Windows system. FILE *file; /* Declare a pointer to a FILE variable */
/* Defined as a global to be available to */
/* other functions */
void OpenDataFile()
{
/* Subroutine to open a data file named "DATAFILE.TXT" in the same directory as the executable file.*/

char file_name[20] = "DATAFILE.TXT";
file = fopen (file_name, "w+");
/* open data file "datafile.txt" */
}

NOTE: The "w+" opens the file to write data to.

Here's a function that will write data to the file you opened. Again, fprintf is a standard ANSI C function. WriteDataToFile writes one data point, a tab character, the next data point and a carriage return/line feed.

void WriteDataToFile(float x_data, float y_data)
{
/* Subroutine to print values into the opened file. "present_time" is */
/* printed in one column, and "temperature" is printed in another. */
/* "present_time" and "temperature" must be sent down from function */
/* main. */

fprintf(file, "%3f\t", x_data); /* write x_data to data file */
fprintf(file, "%.3f\n", y_data); /* write y_data to data file */
}

After you are finished writing all the data to the file, you need to close the file. Here's a function for that. void CloseDataFile()
{
/* Subroutine to close the data file named "DATAFILE.TXT" on the "A:" drive */

fclose (file); /* close data file "a:datafile.txt" */
}

That's all there is to it. These three functions - although somewhat bare bones - will suffice to get a data file for you. The precautions you need to take are:
  • Remember to keep the FILE pointer - *file - outside of all functions so that it is available to all the functions.
  • If you use this function twice (if you run your program twice, for example) the file will be written over, and you will lose your first data set. To get around this, rename the first file immediately.



Creating And Using Flat Files in Visual Basic

Visual Basic has numerous functions for creation and deletion of files, as well as functions that open your files, write data to them and close them.

In this section we'll give you some functions we have written that allow you to create your own data files in a flat file format. You can embed these functions in programs that read laboratory data, and you can use these functions to create files with lab data that you can open in spreadsheets and analysis programs. With that capability you can then plot and analyze your lab data.

The functions we will give you will be the simplest possible. You can then modify these functions to "personalize" them for your own purposes.

The sequence of operations in a typical program might be the following.

  • Open a data file so that you can write data to it.
  • Write data to the file you have open.
  • Close the data file.
First, you need to be able to open a file. That's simple in Visual Basic. Here's the code. Open "DATAFILE.TXT For Output As #99 The Open statement will open a file with the name specified immediately after the word "Open". Normally you will open the file for Output, and you can assign it a number - to be used later in Print and/or Write statements. (Here we used #99.) You can also specify complete path information if the file will be located in another directory other than the one your programming is running in.

After you've opened the file, write data to it using something like this.

Print #99, Xdata, Ydata When you're done writing data to your file, close it. Here's the code. Cl99ose # There are better ways to specify a data file name. You can create A file I/O box using the standard FileListBox, DirListBox and DriveListBox tools. If you're good at Visual Basic, take a shot at that.
<<Previous



Discussion Center

Discuss/
Query

Papers/
Syllabus

Feedback/
Suggestion

Yahoo
Groups

Sirfdosti
Groups

Contact
Us

MEMBERS LOGIN
  
Email ID:
Password:

  Forgot Password?
 New User? Register!

INTERVIEW EBOOK
Get 9,000+ Interview Questions & Answers in an eBook. Interview Question & Answer Guide
  • 9,000+ Interview Questions
  • All Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades
GATE RESOURCES
 
  • Gate Books
  • Training Institutes
  • Gate FAQs
  • GATE BOOKS
     
  • Mechanical Engineeering Books
  • Robotics Automations Engineering Books
  • Civil Engineering Books
  • Chemical Engineering Books
  • Environmental Engineering Books
  • Electrical Engineering Books
  • Electronics Engineering Books
  • Information Technology Books
  • Software Engineering Books
  • GATE Preparation Books
  • Exciting Offers



    GATE Exam, Gate 2009, Gate Papers, Gate Preparation & Related Pages


    GATE Overview | GATE Eligibility | Structure Of GATE | GATE Training Institutes | Colleges Providing M.Tech/M.E. | GATE Score | GATE Results | PG with Scholarships | Article On GATE | GATE Forum | GATE 2009 Exclusive | GATE 2009 Syllabus | GATE Organizing Institute | Important Dates for GATE Exam | How to Apply for GATE | Discipline / Branch Codes | GATE Syllabus for Aerospace Engineering | GATE Syllabus for Agricultural Engineering | GATE Syllabus for Architecture and Planning | GATE Syllabus for Chemical Engineering | GATE Syllabus for Chemistry | GATE Syllabus for Civil Engineering | GATE Syllabus for Computer Science / IT | GATE Syllabus for Electronics and Communication Engineering | GATE Syllabus for Engineering Sciences | GATE Syllabus for Geology and Geophysics | GATE Syllabus for Instrumentation Engineering | GATE Syllabus for Life Sciences | GATE Syllabus for Mathematics | GATE Syllabus for Mechanical Engineering | GATE Syllabus for Metallurgical Engineering | GATE Syllabus for Mining Engineering | GATE Syllabus for Physics | GATE Syllabus for Production and Industrial Engineering | GATE Syllabus for Pharmaceutical Sciences | GATE Syllabus for Textile Engineering and Fibre Science | GATE Preparation | GATE Pattern | GATE Tips & Tricks | GATE Compare Evaluation | GATE Sample Papers | GATE Downloads | Experts View on GATE | CEED 2009 | CEED 2009 Exam | Eligibility for CEED Exam | Application forms of CEED Exam | Important Dates of CEED Exam | Contact Address for CEED Exam | CEED Examination Centres | CEED Sample Papers | Discuss GATE | GATE Forum of OneStopGATE.com | GATE Exam Cities | Contact Details for GATE | Bank Details for GATE | GATE Miscellaneous Info | GATE FAQs | Advertisement on GATE | Contact Us on OneStopGATE |
    Copyright © 2024. One Stop Gate.com. All rights reserved Testimonials |Link To Us |Sitemap |Privacy Policy | Terms and Conditions|About Us
    Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | India Job Forum | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Free Classifieds | Jobs Assist | Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Web Hosting | Quick Site Kit | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Software Testing Interview Questions | Free Online Exams | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
    C Interview Questions | C++ Interview Questions | Send Free SMS | Placement Papers | SMS Jokes | Cool Forwards | Romantic Shayari