Working With Files. Sources of Data Adding data to a spreadsheet can be done in several ways, including: – Type it in piece by piece – Read it from a.

Slides:



Advertisements
Similar presentations
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Advertisements

Computer Basics Hit List of Items to Talk About ● What and when to use left, right, middle, double and triple click? What and when to use left, right,
Excel Formatting. Format Cells… Right-mouse click in the spreadsheet to bring up this drop-down menu.
Introduction to Computing Science and Programming I
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Hand Crafting your own program By Eric Davis for CS103.
Converting Microsoft Office Documents Bill Weber E-Learning Systems Administrator E-Learning Operations.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
Adding Automated Functionality to Office Applications.
Pasewark & Pasewark 1 Access Lesson 6 Integrating Access Microsoft Office 2007: Introductory.
Access Tutorial 8 Sharing, Integrating, and Analyzing Data
1 Access Lesson 6 Integrating Access Microsoft Office 2010 Introductory Pasewark & Pasewark.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Ogden Air Logistics Center. Purpose of Excel2FV Many agencies produce point lists of different data (target lists, force locations, etc.) in either Excel.
HTML and Designing Web Pages. u At its creation, the web was all about –Web pages were clumsily assembled –Web sites were accumulations of hyperlinked.
Excel 2007 Part (2) Dr. Susan Al Naqshbandi
Informer Web Reporting Basic Reporting
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Microsoft Word 2000: Mail Merge Basics Peggy Serfazo Marple Molly Calvello Support Professionals Business Applications - Desktop Microsoft Corporation.
Overview Trackaparcel booking system is very easy to use which sends up to minute information directly to the logistic company whilst building the manifest.
Miscellaneous Excel Combining Excel and Access. – Importing, exporting and linking Parsing and manipulating data. 1.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Copyright © 2008 Pearson Prentice Hall. All rights reserved Copyright © 2008 Prentice-Hall. All rights reserved. Committed to Shaping the Next.
Getting Started with HTML Please use speaker notes for additional information!
Step Two: Import Contacts. As mentioned in Step One, you can Quick Add Contacts one at a time. Adding contacts this way will only require input of the.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
WORKBOOK FORMATTING Nolan Tomboulian Tomboulian.wikispaces.com HOW THINGS LOOK CELL COLORFONT COLOR CELL BORDERSFONT SIZE CELL SIZEFONT.
NOBELCON Version 4.0 USER MANUAL. Get started Obtain Excel spreadsheet with coordinates. Open spreadsheet in Excel. If there are multiple sets of coordinates.
Input and Output. Announcements  Exam Next Wednesday –Next Monday: Review session.  Invited talk: –7:30 PM,Tuesday, Oct 28th. –Prof. Katherine Socha.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
CCS – Mail Merge Mail Merge This presentation is incomplete without the associated discussion 1 Coloma Community Schools In-service 21 March 2014.
1 CS 106 Computing Fundamentals II Chapter 67 “Working With Files” Herbert G. Mayer, PSU CS status 6/24/2013 Initial content copied verbatim from CS 106.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
The Report Generator Viewing Student Outcomes. Install the Report Generator In a browser, go to Click.
Files Tutor: You will need ….
Importing Data to Excel. Suppose you have a delimited* text file and you need to bring it into Excel. Follow these steps… *Delimited means text separated.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
MAIL MERGE Letters, Envelopes & Labels. WHAT IS IT? Handling sending the same thing to a list [maybe Christmas cards?] of people: – Envelopes – Labels.
1 CS 106 Computing Fundamentals II Chapter 210 “Adding Controls to User Forms” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim.
Unit 3: Text, Fields & Tables DT2510: Advanced CAD Methods.
Mail merge I: Use mail merge for mass mailings Overview: Mailings en masse What if you need to send to each of your employees a letter containing personal.
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Copyright © Curt Hill Common Dialogs Easily Obtaining File Names in DevC++ Windows Programs.
Exporting & Formatting Budgets from FlexGen, NextGen & Zortec into Excel.
This was written with the assumption that workbooks would be added. Even if these are not introduced until later, the same basic ideas apply Hopefully.
NXT File System Just like we’re able to store multiple programs and sound files to the NXT, we can store text files that contain information we specify.
Instructions for transferring names and addresses from a MS WORD table (previously created for printing address labels) to MS Excel for upload to SendOutCards.
Revised June 2008 Online PD Basic HTML1 Let’s Try It!  Open Notepad oStart > All Programs > Accessories > Notepad oDon’t get WordPad by mistake – won’t.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 8 BACKNEXTEND 8-1 LINKS TO OBJECTIVES Import data from Access, a Web site, or a CSV text file.
Section 3 Computing with confidence. The purpose of this section The purpose of this section is to develop your skills to achieve two goals: 1-Becoming.
JavaScript: Conditionals contd.
Multi-Axis Tabular Loads in ANSYS Workbench
Introduction to OBIEE:
Step 1: Prepare data in Excel for mail merge
Loops BIS1523 – Lecture 10.
Prepare data for importing
Performing Mail Merges
ECONOMETRICS ii – spring 2018
Exporting & Formatting Budgets from NextGen o Excel
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
What’s New in Colectica 5.3 Part 2
Sirena Hardy HRMS Trainer
Access Tutorial 8 Sharing, Integrating, and Analyzing Data
Microsoft Excel 2007 – Level 2
Click ‘browse’ to search your device for
Tutorial 8 Sharing, Integrating, and Analyzing Data
Presentation transcript:

Working With Files

Sources of Data Adding data to a spreadsheet can be done in several ways, including: – Type it in piece by piece – Read it from a file – Link to a database In this presentation we focus on reading data from a file

Data File Formats There are some standard data formats you can easily read into Excel Perhaps the most common one uses comma separated values (csv) The idea is that the data is in lines of text, one line for each row, with the entries for each column separated by commas Many kinds of software allow you to export data in this format with the idea that you will then read it into Excel

Text Files Many of the files produced by software products have extra information in them besides just text For example, Word documents contain the information about fonts, bold, italics, bullets and indenting, etc., along with the actual text The same is true for Excel files, whether.xlsx or.xlsm A comma separated values file (.csv file extension) is basically just a text file. Using.csv rather than.txt lets Excel know it’s in a format that can be read directly into a spreadsheet

The Input Function The Input function is used to read data from files There are several ways to use it. Examples are in the InputDemo workbook; you should try them out. [It’s especially interesting to try versions of Input on files not designed for them and see what happens.]

Setting up to read… The first step is to open a file for reading. Excel has a nice dialog box that lets the user browse for a file. The next slide shows the relevant code from the InputDemo

Code to open a file.. And close it fName = Application.GetOpenFilename() If fName = False Then 'user cancelled Exit Sub End If Open fName For Input Access Read As #1 Close #1 'close the file you opened

File Number Where we used #1, you can use any number Using the number lets you have several files open and choose which ones to read and/or write to Be sure to close any files you open in your program when you are done with them. Windows will probably take care of this for you, but you risk a corrupted file if you don’t

Reading a Whole Line One way to use Input is to read a whole line at a time. Here is the code for that version: Line Input #1, oneLine Here oneLine is a string variable

Whole Line Text File George Washington John Adams Thomas Jefferson John Quincy Adams Abraham Lincoln

Whole Line Output The program prints a line saying “done” if it finishes normally

Reading a Single Item To read single items, you separate them with commas. Excel is primed to expect comma delimited values It also regards the end of a line as a separator. Here’s the code (oneItem is a string variable): Input #1, oneItem

Single Item Text File George, Washington John, Adams Thomas, Jefferson John, Quincy, Adams Abraham, Lincoln

Single Item Output

You can read multiple items To do this, you provide more than one variable as a target If your file does not have the right number of items, your program will terminate abnormally Here’s the code for reading two items at once: (ours are both strings but you can use other types if you know your data is numbers, for example) Input #1, item1, item2

Two Item Text File George, Washington John, Adams Thomas, Jefferson Andrew, Jackson Abraham, Lincoln

Two Item Result

Odd number result Here we used our one time file, which has an odd number of items. The program terminated abnormally when it couldn’t find an item in the last read

Read N Characters You can also read a block of N characters This may behave in an unexpected way since there are some “invisible” characters in text files, such as carriage return and line feed. Here’s the code; note the different syntax. Variable chars is of type String. chars = Input(N, #1)

The Data File This file ends with a return, which you can’t see. But look at the results…

Reading one character at a time Lines 21 and 22 contain the carriage return and line feed characters

Two at a time: Now line 11 has the carriage return and line feed characters

Four at a Time Abnormal termination. The number of visible characters is 16, but the actual number is 18.

Why Read Characters? You might want to write code that picks out only certain kinds of items from the text, for example. You can use string functions along with concatenation to build up things like a catalog of words in a text while ignoring punctuation Usually, though, reading one item at a time is the right approach