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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Read files with Python3m 12s
-
(Locked)
Write files with Python2m 49s
-
(Locked)
Use Python's command-line interface2m 19s
-
(Locked)
Organize directories with Python3m 19s
-
(Locked)
Parse data with Python6m 9s
-
(Locked)
Extract data with regular expressions2m 51s
-
(Locked)
Validate inputs with automation2m 59s
-
(Locked)
Prepare for error handling2m 43s
-
(Locked)
Automate error handling3m 57s
-
(Locked)
-
-
-
-