Week 9 : Text processing (Reading and writing files)

Slides:



Advertisements
Similar presentations
Week 4 – Functions Introduction. Functions: Purpose Breaking a large problem into a series of smaller problems is a common problem- solving technique.
Advertisements

Review for midterm exam Dilshad M. Shahid Spring NYU.
CP1020 Week 5 Selection Continued. CP1020 University of Wolverhampton - Steve Garner and Ian Coulson if then else zWe can use if then else statements.
Queries and query design What are queries? Questions that can be asked of the data in the tables. Questions can draw on one or more tables and can have.
Whole School Attendance Whole School Attendance 94.64% Overall School Absence 5.36%
Add a File with X, Y coordinates to MapWindow
1 Access Lesson 6 Integrating Access Microsoft Office 2010 Introductory Pasewark & Pasewark.
Unix Filters Text processing utilities. Filters Filter commands – Unix commands that serve dual purposes: –standalone –used with other commands and pipes.
Lines of Latitude + Longitude
Functions.
More on Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Longitude & Latitude The Earth’s Grid.
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
Data Organization Data Collection and Spreadsheets.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Hashim, Mike, Connor. It allows the user to combine a document with a data file to send form letters to many recipients. Each letter is personalized for.
Programming Project (Last updated: August 31 st /2010) Updates: - All details of project given - Deadline: Part I: September 29 TH 2010 (in class) Part.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Data Types Integer 15 StringHelloThere! Float/Real BooleanYes / No CharP.
3202 / 3200 / 3260 Climate Graphs WORLD GEOGRAPHY 3202 / 3200 / 3260 Climate Graphs Mr. Oliver H. Penney.
Line Graphs. Lets look at some average temperatures from some cities around the world…
If statements while loop for loop
Manipulating Text In today’s lesson we will look at: why we might want to pick out parts of text strings some BASIC functions that can be used to chop.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
By Rachel Thompson and Michael Deck.  Java.io- a package for input and output  File I/O  Reads data into and out of the console  Writes and reads.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
Maths in Python [ slide 5 ] 1.Copy the table 2.Race a friend with a calculator to see whether Python is faster than a calculator: a) 5 * 6.5 = b)7 / 3.
CCS – Mail Merge Mail Merge This presentation is incomplete without the associated discussion 1 Coloma Community Schools In-service 21 March 2014.
Section 9A Functions: The Building Blocks of Mathematical Models Pages
Ayers Rock Country: Australia State: Northern Territory Elevation: 863 m (2,831 ft) Prominence:348 m (1,142 ft) Coordinates: 25°20′42″S 131°02′10″E.
A Level Computing#BristolMet Session ObjectivesU2#S12 MUST describe the terms modal and pretty printing in term of input and output facilities. SHOULD.
Week 6 : Sequences ( lists, strings, and tuples ).
Week 4 : Function with parameters and return values.
Climate and location of Puerto Rico. Location of Puerto Rico Relative location vs. Absolute location
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake An Introduction to Programming.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
HACC Data Repository Using System Reports in the HACC Data Repository August, 2013.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
1 CSC103: Introduction to Computer and Programming Lecture No 28.
Find that place..  Find that content  Longitude, East is to the right, West is to the left of the Prime Meridian or 0 degrees  Latitude, North is going.
Week 7 : String and photo processing. Today’s Tasks  Practice list and string  Convert Decimal to any radix base number  Between Binary and Hexadecimal.
Making Pages Dynamic Chapter 8 JavaScript for the WWW.
11 Project 2 Temperature Conversion. 22 Project 2: Temperature Conversion Write an ASP.NET Web Forms app to convert temperatures from Fahrenheit to Celsius.
Arrays Collections of data Winter 2004CS-1010 Dr. Mark L. Hornick 1.
Common Mistakes with Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
02CO, p. 29. Fig. 2.1, p. 30 Fig. 2.2, p. 31 Fig. 2.3, p. 31.
Writing Rules for Linear Functions. We compared slopes across three different representations – graphs, tables, and in equations. Functions are similar,
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Input, Output and Variables GCSE Computer Science – Python.
ENGINEERING 1D04 Tutorial 2. What we’re doing today More on Strings String input Strings as lists String indexing Slice Concatenation and Repetition len()
Creates the file on disk and opens it for writing
Seasons.
Data Types and Conversions, Input from the Keyboard
Python I/O.
Use proper case (ie Caps for the beginnings of words)
Year 2 Autumn Term Week 12 Lesson 1
Where in the World.
Creates the file on disk and opens it for writing
Year 2 Autumn Term Week 12 Lesson 1
Functions Rules and Tables.
For Documents and Pages Robert Herriot, Xerox
Input and Output Python3 Beginner #3.
Surface Systems.
Excel Tips & Tricks July 18, 2019.
Challenge Guide Grade Code Type Slides
Presentation transcript:

Week 9 : Text processing (Reading and writing files)

Today’s Tasks  Task 1 – Merge a set of files into a new file  Task 2 – Handle coordinate information from a file  Task 3 – Handle temperature information from a file

Task 1  Merge a set of input files into a single output file. All the contents in a set of the input files are put into the single output file Define a function ‘merge’.  INPUT 1 (1 st parameter): names of a set of input files (list of strings)  INPUT 2 (2 nd parameter): a name of a single output file (string)  OUTPUT: None 1-2. Merge example input files by calling the function ‘merge’.  e.g) merge([“kaist1.txt”, “kaist2.txt”, “kaist3.txt”], “result.txt”)

Task Read and print data from the file ‘average-latitude-longitude- countries.csv’  Each line (except for the head) contains country code, country name, latitude and longitude, which are comma-separated  e.g.) "KR","Korea, Republic of",37,127.5  -90.0° ≤ latitude ≤ 90.0 °, ° ≤ longitude ≤ °  Caution: Several country names contain comma  Make two lists and print them  List of tuples ( country code, country name )  List of tuples ( country code, (latitude, longitude) )  Data type –string : country code, country name –float : latitude, longitude 2-2. Print the names of all countries whose location lies in the south of the equator 2-3. Let the user enter a country code, and then print the full name of the corresponding country

Task 3 (1/2)  Handle England’s monthly temperature information for the years 1723~1970  2 sub-tasks 3-1. Read the data and print average winter and summer temperatures for each year  Winter average = ( January’s + February’s ) / 2  Summer average = ( July’s + August’s ) / 2  Print every year and summer and winter average temperatures in a nicely formatted table  e.g.) … 1737: 5.2/ : 4.6/ : 5.4/ : -2.2/ : 3.1/ : 2.8/ : 4.5/15.9 …

Task 2 (2/2) 3-2. Write the contents in another format  To the file ‘C:/CS101/tpmon.csv’  Each year and its 12 monthly averages in one line  write in CSV format (i.e. comma-separate the data)  Try to open the file in Excel 1723,1.1,4.4,7.5,8.9,11.7,15.0,15.3,15.6,13.3,11.1,7.5, ,5.6,4.2,4.7,7.2,11.4,15.3,15.0,16.2,14.4,8.6,5.3, ,4.4,3.3,5.0,8.1,10.8,12.2,13.8,13.3,12.8,9.4,6.9, ,1.1,4.2,4.2,8.4,13.4,16.4,16.0,15.6,14.7,10.2,6.1, ,4.2,5.0,5.1,9.2,13.6,14.9,16.9,16.9,14.4,10.8,4.7, ,3.9,2.4,7.1,8.3,12.5,16.4,16.9,16.0,12.8,9.1,7.2, ,1.2,2.3,2.8,7.1,10.3,15.1,16.8,15.7,16.6,10.1,8.1, ,4.1,4.7,6.2,8.7,12.4,14.0,15.3,16.3,15.3,10.9,9.2, ,1.9,2.2,6.0,6.8,12.1,15.6,16.3,16.7,15.3,12.3,7.8, ,2.4,6.4,6.1,8.9,11.4,14.6,16.0,16.6,14.5,10.9,6.3, ,6.9,6.0,5.9,10.0,11.2,15.2,18.3,16.1,12.8,9.1,6.5, ,4.3,6.4,8.1,9.3,11.1,14.1,16.2,16.2,13.3,8.4,6.2,4.0 …

Any Questions?