Thursday, March 7, 2019

Thursday March 7, 2019 - writing .txt files in Python


Mechatronics Engineering Google Site
Special Instructions:

Entry Ticket - House Keeping
Mechatronics Engineering Plan For Today:
  • Entry Ticket 
  • Python - Reading Files
  • Open Lab
  • Clean Up




Python - Files
  • LAB - Duration: 60 Min
  • Link: Pythonlearn-07-Files
    • Python  Files
      • Open the mbox-short
      • find all the emails
      • write them to a file
      • the out put should just be a list of emails one each line:
stephen.marquard@uct.ac.za
postmaster@collab.sakaiproject.org
200801051412.m05ECIaH010327@nakamura.uits.iupui.edu
source@collab.sakaiproject.org
source@collab.sakaiproject.org
source@collab.sakaiproject.org

emailList=list()  # Creating a List
print(emailList)
# xfile=open('mbox-short-short.txt')
#fname=input('enter a file name ')
fname="mbox-short-short.txt"
try:
    fhand=open(fname)
except:
    print('bad dog... no file found')
    quit()
# Challenge
print(fhand)

for variableNamedLine in fhand:
 
    lineListEmail=variableNamedLine.split()
    for i, email in enumerate(lineListEmail):
        if '@' in email:
            print('An email was found at list location ',i, 'and is ',lineListEmail[i])
            emailList.append(lineListEmail[i])
print('this is just the emails')
print(emailList)


Open LAB  and/or Robot Club 
  • LAB - Duration: 40 Min
  • Link: Robot Club Google Sites
  • Instructions & Expectations: Connect with your Robot Club Team.  You will either be working on your Robot Project or an Open Lab Project.  
    • You will need to account for your time. You will need to convince me by your form submission that you worked given the time allotted. 
    • If  you or your Robot Club Team worked on the Robot Club project, you will make sure your Robot Project Status Google docs are updated.  
    • If you worked on an Open Lab Project, you will also need to tell me about what you accomplished and what you are planning next.
  • How to Submit Assignment:   Each Student needs to account for your time.  
  • Dig Deeper: Open Lab:
Clean Up
  • Assignment - Duration: 2-10 Min
  • Instructions & Expectations: Desk cleanup, put away all projects, find your assigned job
  • How to Submit Assignment: When Complete, check yourself off on Sign Out Sheet - 2 Points

No comments:

Post a Comment