Programming Languages Meeting 12 November 18/19, 2014.

Slides:



Advertisements
Similar presentations
Bioinformatics is … - the use of computers and information technology to assist biological studies - a multi-dimensional and multi-lingual discipline Chapters.
Advertisements

1 Unix Talk #2 AWK overview Patterns and actions Records and fields Print vs. printf.
ISBN Regular expressions Mastering Regular Expressions by Jeffrey E. F. Friedl –(on reserve.
2000 Copyrights, Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 6.
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
CSC 4630 Meeting 9 February 14, 2007 Valentine’s Day; Snow Day.
AWK: The Duct Tape of Computer Science Research Tim Sherwood UC San Diego.
Scripting Languages CS351 – Programming Paradigms.
Scripting Languages. Originally, a script was a file containing a sequence of commands that needed to be executed Control structures were added to make.
Guide To UNIX Using Linux Third Edition
Computer Science 210 Computer Organization Introduction to C.
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
Agenda Sed Utility - Advanced –Using Script-files / Example Awk Utility - Advanced –Using Script-files –Math calculations / Operators / Functions –Floating.
General Programming Introduction to Computing Science and Programming I.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
Input, Output, and Processing
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Programming Languages Meeting 13 December 2/3, 2014.
Computer Science 101 Introduction to Programming.
Programming Languages Meeting 6 September 30, 2014 October 1, 2014.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Introduction to Awk Awk is a convenient and expressive programming language that can be applied to a wide variety of computing and data manipulation tasks.
Programmable Text Processing with awk Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users”
Awk Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Sed, awk, & perl CS 2204 Class meeting 13 *Notes by Mir Farooq Ali and other members of the CS faculty at Virginia Tech. Copyright 2003.
Introduction to PHP Advanced Database System Lab no.1.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
Programming Languages Meeting 14 December 9/10, 2014.
A talk about AWK Don Newcomb 18 Jan What is AWK? AWK is an interpreted computer language It is primarily used for text processing and data formatting.
LIN Unix Lecture 7 Hana Filip. LIN Text Processing Command Line Utility Programs (cont.) sed LAST WEEK wc sort tr uniq awk TODAY join paste.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Computer Programming for Biologists Class 6 Nov 21 th, 2014 Karsten Hokamp
Chapter Twelve sed, awk & perl1 System Programming sed, awk & perl.
© 2006 KDnuggets [16/Nov/2005:16:32: ] "GET /jobs/ HTTP/1.1" "
16-Dec-15Advanced Programming Spring 2002 sed and awk Henning Schulzrinne Dept. of Computer Science Columbia University.
CSCI 330 UNIX and Network Programming
Awk- An Advanced Filter by Prof. Shylaja S S Head of the Dept. Dept. of Information Science & Engineering, P.E.S Institute of Technology, Bangalore
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 6 – sed, command-line tools wrapup.
1 P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Awk Programming Ruibin Bai (Room AB326) Division of Computer Science The University.
The awk command. Introduction Awk is a programming language used for manipulating data and generating reports. The data may come from standard input,
Sed. Class Issues vSphere Issues – root only until lab 3.
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
PZ02CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02CX - Perl Programming Language Design and Implementation.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Awk 2 – more awk. AWK INVOCATION AND OPERATION the "-F" option allows changing Awk's "field separator" character. Awk regards each line of input data.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Organization of Programming Languages Meeting 37 April 18, 2016.
Arun Vishwanathan Nevis Networks Pvt. Ltd.
Introduction to Perl: Practical extraction and report language
CSE 374 Programming Concepts & Tools
CSC 4630 Meeting 7 February 7, 2007.
CS 330 Class 7 Comments on Exam Programming plan for today:
Computer Science 210 Computer Organization
Perl Programming Language Design and Implementation (4th Edition)
PROGRAMMING THE BASH SHELL PART IV by İlker Korkmaz and Kaya Oğuz
John Carelli, Instructor Kutztown University
Computer Science 210 Computer Organization
Introduction to Python
Guide To UNIX Using Linux Third Edition
Programming Languages
Programming Languages
Awk.
Presentation transcript:

Programming Languages Meeting 12 November 18/19, 2014

Short Exam Results Computer programming requires precise notation: Missing ; Wrong case Mismatched parentheses There were many sloppy answers to questions. The reprise on the next slides gives you the opportunity to be precise.

Short Exam Reprise Submit by Friday, November 20, 2014, no later than 5:00 p.m. a text file attached to an message containing the implementation in Lisp using our development rules of the functions: reverse concat IG

Short Exam Answers

GetFloat Project Code checked – Comments – getc implemented – getfloat implemented – input file specification Output checked – File of correct floats – File of floats with line numbers – File of floats mingled with character strings – File with no floats, but some look temptingly good

Matrix Project Helpfulness of LispWorks – Bug when functions are redefined – Solution: Define myfirst, mylast Primitives and functionals submitted? Questions?

Preparations for Tonight Unix cluster access?

Scripting Languages Originally, tools for – Quick, dirty programs – Rapid prototyping for text-based computation – Glue between other programs – File format conversion Evolved to mainstream programming tools – Check current estimates on the number of lines of Javascript code doing productive work

Characteristics Strings as the basic, maybe only, data type Associative arrays (hashes?) as the basic structured data type Regular expressions as a principle programming structure Minimal use of types and declarations Usually interpreted rather than compiled

Examples Unix shell AWK Perl Python Tcl Javascript VBScript, Jscript PHP

Our Approach Look at AWK and Perl first Determine the syntactical structure of each language, starting with AWK Use experimentation to discover the semantics Work several exercises on each language during class time

AWK Age: 38 years Developed at Bell Labs by Al Aho, Brian Kernighan, Peter Weinberger – Aside: Where are each of these computing pioneers now? Intended for simple manipulation of, and data extraction, from text files – 38 years ago data existed in text files almost exclusively

AWK Examples Print all lines longer than 80 characters. length > 80 Replace the second field in each line by its logarithm. { $2 = log($2); print } Add up the numbers in the first field and report the sum and average. { sum += $1 } END { print sum, sum/NR }

AWK Syntax ::= [ ] [ ] ::= { } ::= | { } | { } ::= BEGIN { } ::= END { }

Heart of AWK – A regular expression – A numeric expression – A combination of the previous two – Executable code, similar in structure to C

Inferred Control Structure Previous languages: sequence – Execute S1, then S2, then S3, … AWK: a triply nested for-loop surrounding an if-then. Specifically for each file for each input line for each pattern if pattern matches input line then action

Program Development Use your favorite text editor to create an AWK program file. Run the program awk –f myprog [file1 file2 … ] OR for really short programs (one line) awk ‘program’ [file1 file2 …]

Some Interesting Data From the course website, under Resources, download the four data files – Flight Aware data – Moby Dick extract – Web form data – Classic AWK data on countries (these data come from the 1985 AWK manual)

Some AWK Programs Try each of these programs using flightaware.txt as the input file { print NR, $0 } { $1 = NR; print } Note that is surrounded by { } and may consist of several statements separated by ;

More Programs {print $NF} /Cancelled/ END {print NR}

AWK Built-Ins NF – number of fields on a line NR – number of lines (records) in a file, actually the number of the current line read in the file $k – name of the k th field, count starts at 1 $0 – name of the current line FILENAME – name of current input file

More Built-Ins FS – field separator, typically reset in the BEGIN action if something other than space is needed OFS – output field separator RS – record separator ORS – output record separator OFMT – output format

Your Turn Write AWK programs to: 1.Determine how many flights were cancelled 2.Find the latest arriving flight from those in the list 3.List the different aircraft used for this flight number.