CIT 590 Intro to Programming Files etc. Announcements From HW5 onwards (HW5, HW6,…) You can work alone. You can pick your own partner. You can also stick.

Slides:



Advertisements
Similar presentations
E-books and E-journals Off-campus This presentation will show you how to log in and access Oxford Brookes Library e-books and e-journals when youre off.
Advertisements

Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
E-books and E-journals Off-campus This presentation will show you how to log in and access Oxford Brookes Library e-books and e-journals when youre off.
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Whats New in Office 2010?. Major Changes in Office 2010 The Office Ribbon, which first made its appearance in Office 2007, now appears in all Office 2010.
 Computer Science 1MD3 Introduction to Programming Winter 2014.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
C Programming - Lecture 3 File handling in C - opening and closing. Reading from and writing to files. Special file streams stdin, stdout & stderr. How.
Some things to think about. Assignment 1 is at the end, but read the whole thing. Please!
1 Spidering the Web in Python CSC 161: The Art of Programming Prof. Henry Kautz 11/23/2009.
(c) Manzur Ashraf, Short course, KFUPM PHP & MySQL 1 Basic PHP Class 2.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
Files COP3275 – PROGRAMMING USING C DIEGO J. RIVERA-GUTIERREZ.
A SIR web based leave/absence management system. By Dave Doulton University of Southampton.
Guide to Programming with Python Chapter Seven (Part 1) Files and Exceptions: The Trivia Challenge Game.
Electronic Etiquette Communication Skills for and Blogs.
PHP meets MySQL.
CS190/295 Programming in Python for Life Sciences: Lecture 3 Instructor: Xiaohui Xie University of California, Irvine.
16-Oct-15 JSP Implicit Objects. 2 JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer.
File I/O Static void Main( ) {... } data. Topics I/O Streams Reading and Writing Text Files Formatting Text Files Handling Stream Errors File Pointers.
CIT 590 Intro to Programming Lecture 4. Agenda Doubts from HW1 and HW2 Main function Break, quit, exit Function argument names, scope What is modularity!
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
Course A201: Introduction to Programming 12/9/2010.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
Chapter 9-Text File I/O. Overview n Text File I/O and Streams n Writing to a file. n Reading from a file. n Parsing and tokenizing. n Random Access n.
PHP. $_GET / $_POST / $_SESSION PHP uses predefined variables to provide access to important information about the server and requests from a browser.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Guide to Programming with Python Chapter Seven Files and Exceptions: The Trivia Challenge Game.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Files Tutor: You will need ….
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
A Few Key Vocab Words That you should know! By Dr. Bowie.
| imodules.com Top 10 FAQ in Application Support Kelly Schmiedeler & Amber Quayle.
GEO375 Final Project: From Txt to Geocoded Data. Goal My Final project is to automate the process of separating, geocoding and processing 911 data for.
Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
FILES. open() The open() function takes a filename and path as input and returns a file object. file object = open(file_name [, access_mode][, buffering])
CS116 COMPILER ERRORS George Koutsogiannakis 1. How to work with compiler Errors The Compiler provide error messages to help you debug your code. The.
CIT 590 Intro to Programming Files etc. Agenda Files Try catch except A module to read html off a remote website (only works sometimes)
1 1.Log in to the computer in front of you –Temp account: 210class / 2.Update your in Cascadia's system –If I need to you I'll use.
CIT 590 Intro to Programming Lecture 6. Vote in the doodle poll so we can use some fancy algorithm to pair you up You.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Weebly Elements, Continued
Topic: File Input/Output (I/O)
CMSC201 Computer Science I for Majors Lecture 12 – Lists (cont)
Python’s input and output
CSC 108H: Introduction to Computer Programming
Log in to the computer in front of you
Learning Objectives What else in C++ Bitwise operator
Python I/O.
File Handling Programming Guides.
Topics Introduction to File Input and Output
Using files Taken from notes by Dr. Neil Moore
Learning to Program in Python
CISC101 Reminders Quiz 2 graded. Assn 2 sample solution is posted.
How to save information in files open, write, close
Files Handling In today’s lesson we will look at:
15-110: Principles of Computing
Topics Introduction to File Input and Output
Winter 2019 CISC101 4/29/2019 CISC101 Reminders
Topics Introduction to File Input and Output
How to read from a file read, readline, reader
Introduction to Computer Science
Presentation transcript:

CIT 590 Intro to Programming Files etc

Announcements From HW5 onwards (HW5, HW6,…) You can work alone. You can pick your own partner. You can also stick to the same partner for every single HW. Decision has to be communicated to us by Sunday evening 6pm. No communication = solo. Please do not send me saying you are working alone. Please put CIT590 in the subject For any given week, after 6pm on Sunday No changing of pairs allowed after that. Cannot go from solo to pair after that. Cannot go from pairs to solo after that either. You are allowed to make a fresh decision each week.

Agenda Files Try catch except A module to read html off a remote website (only works sometimes)

Basic file operations f = open(‘myRandomFile.txt’) Open(“”) Default is the read only mode Open(“”, “w”) Open the file in the mode that you would like to use it Read - r Write - w Append – a Opening a file in the ‘r+’ mode if you want to read and write to it at the same time. Use this one with caution

Reading and writing to a file Read, readline, readlines Read – reads the whole file in as a string Readline – read it line by line. Each line is read as a string Readlines – reads in all the lines as a list Using a while loop to read every single line of a file Write, writelines fileExperiments.py

Closing a file Close() – why should I close a file Cleaning up The operating system should close the file, but that behavior is not entirely under your control Remember that opening a file for writing will remove the old values

Looping through the contents of a file Line = f.readLine() and then follow it up by while line: Instead of using a while loop with a readline, python provides the ability to do a for loop for x in f: That will go through the file line by line and each time a full line will be assigned to the variable x Then you can do fun things with x How does the HW4 code work?

Tell and seek Once I have read a file all the way through how do I go back to the start?? Or in general, how do I mark a point in the file that I now want to come back to. x = f.tell() #do some reading writing etc etc on f f.seek(x) to get back to where we were

What file formats are supported? Text files work best in that they do not come with headers and footers etc You can always read in binary but it is ‘yucky’ Csv files work as well Usually if you are dealing with a specific format, you will be using some extra packages

Exceptions! Try except try: Something except error, e: do something with the error. Maybe print some message else: #it was a successful attempt. Now do the real work tryExceptForFiles.py

The file sort example from the book Good example for top down design What if you had to sort a massive file that cannot possibly be stored all in memory fileSort.py

Reading from a url Import urllib Urllib.urlopen( Only works on a subset of sites. Secure sites will usually not allow you to grab info that easily. My seas website isn’t particularly secure …. getAllTAs.py