Processing Text Excel can not only be used to process numbers, but also text. This often involves taking apart (parsing) or putting together text values.

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

Python Basics: Statements Expressions Loops Strings Functions.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
MIS: Chapter 14 Cumulative concepts, features and functions, plus new functions COUNTIFS, SUMIFS, AVERAGEIFS (Separate ppt on REACH.louisville.edu) All.
This is a powerpoint to teach number sense tricks
CS1100: Computer Science and Its Applications Text Processing Created By Martin Schedlbauer
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Multiplication of Fractions
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 11 1 Microsoft Office Excel 2003 Tutorial 11 – Importing Data Into Excel.
CS 255: Database System Principles slides: Variable length data and record By:- Arunesh Joshi( 107) Id: Cs257_107_ch13_13.7.
Dividing Polynomials.
A table is an arrangement of data (words and numbers) in rows and columns. Tables range in complexity from those with only two columns and a title to.
Spreadsheets Objective 6.02
2 Explain advanced spreadsheet concepts and functions Advanced Calculations 1 Sabbir Saleh_Lecture_17_Computer Application_BBA.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Chapter 9 Creating Formulas that Manipulate Text Microsoft Office Excel 2003.
Importing Data Text Data Parsing Scrubbing Data June 21, 2012.
Using Excel for A – Z Analysis: ‘To Present’ items Jack Weinbender, Milligan College.
Excel has a number of Count Functions that will total the number of cells in a selected range. We’re going to look at: COUNT COUNTA COUNTBLANK COUNTIF.
Lists in Python.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
General Programming Introduction to Computing Science and Programming I.
Miscellaneous Excel Combining Excel and Access. – Importing, exporting and linking Parsing and manipulating data. 1.
Chapter 1 Working with strings. Objectives Understand simple programs using character strings and the string library. Get acquainted with declarations,
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
Fall Week 4 CSCI-141 Scott C. Johnson.  Computers can process text as well as numbers ◦ Example: a news agency might want to find all the articles.
Colleague, Excel & Word Best of Friends Presented by: Joan Kaun & Yvonne Nelson College of the Rockies.
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.
Area of the Lovely El “Area” means the space taken up by this shape… … so really, we should imagine it ‘filled in.’ (You could shade it in with your pencil.
 Agenda: 4/24/13 o External Data o Discuss data manipulation tools and functions o Discuss data import and linking in Excel o Sorting Data o Date and.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
Fundamentals of Python: First Programs
CSC 211 Data Structures Lecture 13
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Review 1 Arrays & Strings Array Array Elements Accessing array elements Declaring an array Initializing an array Two-dimensional Array Array of Structure.
More Strings CS303E: Elements of Computers and Programming.
Working with Strings. Learning Objectives By the end of this lecture, you should be able to: – Appreciate the need to search for and extract information.
This is a new powerpoint. If you find any errors please let me know at
Working with Strings. String Structure A string in VBA can be variable length and has an internal structure Each character in the string has a position.
NUMBER SENSE AT A FLIP.
CS1100: Computer Science and Its Applications Text Parsing in Excel Martin Schedlbauer, Ph.D.
Excel Text Functions 1. LEFT(text, [num_chars])) Returns the number of characters specified starting from the beginning of the text string Syntax Text:
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
C language + The Preprocessor. + Introduction The preprocessor is a program that processes that source code before it passes through the compiler. It.
Exporting & Formatting Budgets from FlexGen, NextGen & Zortec into Excel.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
13/06/ Strings Left, Right and Trim. 213/06/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Loop Design What goes into coding a loop. Considerations for Loop Design ● There are basically two kinds of loops: ● Those that form some accumulated.
Advanced Excel Helen Mills OME-RESA.
Sorts, CompareTo Method and Strings
Excel IF Function.
Miscellaneous Excel Combining Excel and Access.
Creates the file on disk and opens it for writing
Data Validation and Protecting Workbook
Data types Numeric types Sequence types float int bool list str
Manipulating Text In today’s lesson we will look at:
Creates the file on disk and opens it for writing
CS 106 Computing Fundamentals II Chapter 66 “Working With Strings”
Click ‘browse’ to search your device for
Topic 6 Lesson 1 – Text Processing
Introduction to Computer Science
Topic 3 Lesson 2 – Flexible Models
Chapter 17 JavaScript Arrays
MS Excel – Analyzing Data
The Basics of Excel Part I Monday, April 3rd 2017
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Excel Tips & Tricks July 18, 2019.
Introduction to Computer Science
Presentation transcript:

Processing Text Excel can not only be used to process numbers, but also text. This often involves taking apart (parsing) or putting together text values (strings). The parts into which we split a string will be called fields. Fields may be separated by delimiting text And/or fields may have a fixed width which permits them to be identified. CS1100Text Parsing in Excel1

Example Text processing is often necessary when files are imported from other programs: We’d like to extract the customer name and the payment terms from the text in column A. CS1100Text Parsing in Excel2

Text Processing Functions Excel provides a number of functions for parsing text: – RIGHT – take part of the right side of a text value – LEFT – take part of the left side of a text value – MID – take a substring within a text value – LEN – determine the number of characters in a text value – FIND – find the start of a specific substring within a text value CS1100Text Parsing in Excel3

LEFT Function The LEFT function extracts a specific number of characters from the left side of a text value: CS1100Text Parsing in Excel4 =LEFT(A1,4)

RIGHT Function The RIGHT function extracts a specific number of characters from the right side of a text value: CS1100Text Parsing in Excel5 =RIGHT(A1,4)

MID Function The MID function extracts some number of characters starting at some position within a text value: CS1100Text Parsing in Excel6 =MID(A1,5,4)

FIND Function FIND returns the position where a substring starts within a string. Finds the first occurrence only. Returns a #VALUE! error if the substring cannot be found. CS1100Text Parsing in Excel7 =FIND("DEF",A1) =FIND(" ",A2) =FIND(",",A3)

Case Sensitivity Note that FIND is case sensitive. As an alternative, Excel has a SEARCH function which is not case sensitive but otherwise works the same way as FIND. CS1100Text Parsing in Excel8 =FIND("cde",A16) =SEARCH("cde",A17)

IFERROR and FIND Since FIND returns an error when a substring cannot be found, we need to use a sentinel value. CS1100Text Parsing in Excel9 =FIND("[",A5) =IFERROR(FIND("[",A5),"")

LEN Function The LEN function returns the total number of characters in a text, i.e., the “length” of the text value: CS1100Text Parsing in Excel10 =LEN(A9)

TRIM Function The TRIM function removes all spaces before and after a piece of text. Spaces between words are not removed. This is useful if the text you are trying to parse has trailing spaces which may result in errors later – For example, if you need to use a result later in a VLOOKUP function. CS1100Text Parsing in Excel11

Example 1 – Delimiting Text You are given a list of usernames, each followed by a comma, then a space, then the user’s full name A comma followed by a space only appears between the username and full name Everything following the username, the comma and the space is the user’s full name CS1100Text Parsing in Excel12

Locating the Delimiter (where to split the text) The first step is to identify the location where the split will be made The split location may be identified by – Delimiting text – A fixed width field CS1100Text Parsing in Excel13

Delimiting Text Delimiting text is any sequence of characters that can reliably be used to end one part of the text to be split and the beginning of another. In this example, a comma followed by a space can serve as delimiting text. On the other hand, the width of each field may vary, so we cannot identify the splitting location by field widths CS1100Text Parsing in Excel14

Finding the Delimiting Text Since the width of each field may vary, and we cannot identify the splitting location by field widths, we need to find the location of the comma and space Use FIND to return the location of the delimiter. =FIND(“, ”,A2) CS1100Text Parsing in Excel15

Splitting the Text Once we have found the delimiting text, we can split the original text using functions like LEFT, RIGHT and MID Note that we must adjust the length in our function to omit the delimiting text. =LEFT(A2, B2 – 1) CS1100Text Parsing in Excel16

Splitting the Text Using the RIGHT function to find the full name, we need to find the number of characters from the right – Subtract the length of the whole text by the location of the delimiter and adjust to omit the delimiter CS1100Text Parsing in Excel17 =RIGHT(A2, E2 – B2 – 1)

Splitting the Text We could also use the MID function … CS1100Text Parsing in Excel18 =MID(A2, B2+2, E2)

Divide and Conquer Divide and Conquer is a strategy for solving problems by breaking up a big problem into similar smaller problems – Example: suppose we are given a username, followed by a comma and a space, followed by a real name, followed by another comma and a space, followed by a job title. CS1100Text Parsing in Excel19

Divide and Conquer Split Once Our first step will be to split the original text into two parts 1.A username 2.Everything else CS1100Text Parsing in Excel20

Divide and Conquer Split Again Repeat the splitting process by splitting the remainder into the full name and the job title CS1100Text Parsing in Excel21 Using this strategy, we could repeat the splitting process into smaller and smaller pieces until we have solved the problem. In the above example, we are done.

Parsing Optional Data Sometimes we need to split some text into parts, but one of the parts may be missing. A reasonable first step is to determine whether or not the data is present. CS1100Text Parsing in Excel22

Parsing Optional Data Example Suppose we are given a list of usernames optionally followed by commas and a full name Use IFERROR and FIND to see if there is a comma and return the position if so. CS1100Text Parsing in Excel23

Parsing Optional Data Example Now use an IF statement to extract the username CS1100Text Parsing in Excel24

Parsing Text To extract parts of a text value (parsing) requires thoughtful analysis and often a divide-and-conquer approach. CS1100Text Parsing in Excel25

Strategy You need think about your strategy: – How do I detect where the first name starts? – Are there some delimiters? – What is the delimiter? – Does it always work? – Is there always a first or last name? Break the problem into several problems and create auxiliary or helper columns. CS1100Text Parsing in Excel26

HIDDEN COLUMNS Solving complex parsing problems often requires the use of intermediate values: – Solve the problem in pieces, don’t do it all in a single formula So, place intermediate values into temporary columns and then hide the column to make the model less confusing to read. CS1100Text Parsing in Excel27

COUNTA Function We have already seen COUNT as a way to count the number of cells in a range. However, COUNT only counts cells that contain numbers. – What about text? To count the number of cells that contain some value (either text or number), use COUNTA. CS1100Text Parsing in Excel28

COUNTBLANK Function As an alternative to COUNTA, there is COUNTBLANK. This function counts the number of cells in a range that do not contain any value (either text or number). CS1100Text Parsing in Excel29

Let’s Put This Together… Let’s see if we can parse the text into its name and terms components… Before starting with formulas, think about your strategy. – How can you recognize the beginning and end of the name component? – How about the beginning and end of the terms component? – Do we need intermediate values? CS1100Text Parsing in Excel30