From the course: Using Python for Automation

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Write files with Python

Write files with Python - Python Tutorial

From the course: Using Python for Automation

Write files with Python

- File manipulation automation can really be a game changer. With this, your scripts are unchained and can access external files anywhere, and your datasets now persist even after the program has finished running. In this lesson, you'll explore how to use automation to write files in Python based on specific conditions and verify that the files were created properly. Open write_files_starter_code.py from the exercise files folder. This contains some starter code with comments that guide you through the parts you'll fill in yourself as you follow along. The first line of code opens inputFile.txt with the intention of reading it. This input file contains some data about people who've recently taken their behind the wheel drive test. Each row has the first name of the person, their age, and whether they passed or failed their test. The letter P indicates passing the test and the letter F indicates failing the test. Your goal is to write all of the lines that pertain to people who passed…

Contents