Skip to content

Instantly share code, notes, and snippets.

@manichabba
Created August 15, 2016 14:10
Show Gist options
  • Save manichabba/fc28e583fd12db648423ca2aae5bcfa6 to your computer and use it in GitHub Desktop.
Save manichabba/fc28e583fd12db648423ca2aae5bcfa6 to your computer and use it in GitHub Desktop.
Finding Numbers in a Haystack In this assignment you will read through and parse a file with text and numbers. You will extract all the numbers in the file and compute the sum of the numbers.
import re #using regular expressions
print sum(map(int, re.findall('[0-9]+',open('RegexSum289081.txt').read())))
#Outline-read the file, look for integers using the re.findall(),converting the extracted strings to integers and summing up the integers.
@Immaculate75
Copy link

Counting Organizations

This application will read the mailbox data (mbox.txt) and count the number of email messages per organization (i.e. domain name of the email address) using a database with the following schema to maintain the counts.

CREATE TABLE Counts (org TEXT, count INTEGER)

When you have run the program on mbox.txt upload the resulting database file above for grading.

If you run the program multiple times in testing or with dfferent files, make sure to empty out the data before each run.

You can use this code as a starting point for your application: http://www.py4e.com/code3/emaildb.py.

The data file for this application is the same as in previous assignments: http://www.py4e.com/code3/mbox.txt.

Can someone please help us solve the problem above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment