$30
### Program Instructions:
First, you will create the starting data text file.
1. Open Notepad (or any other plain text editor) and add the following data to the file
2. Save the file
3. Define program variables. You will read the records from this text file into a list in your program. Define a list variable to hold the data (i.e., recordsList). Define and initialize a record count variable to be used later (i.e., recordCount).
- *Reference*: Refer back to your Unit 4 readings from Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 7: Lists.
4. Define a file handle and open your text data file for reading.
- *Hint*: If you want to reference the file by its name using a relative file path like `“IT244_U5_Data.txt”`, this file must exist in the same folder with your Python source code (.py) file. Otherwise, you will need to include the full file path, such as `C:/MyFolder/MySubFolder/MySubSubFolder/MyFile.txt`
- *Reference*: Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 9: Defining a Path to a File / Reading From and Writing to a File / File Handle.
5. Use a for loop to access each record in the file and append each record to the list variable each iteration.
- *Hint*: Use strip to remove any line breaks like recordsList.append(line.strip())
- *Reference*: Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 9: Writing and Reading a Line at a Time With a File.
6. Close the file.
- *Reference*: Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 9: Defining a Path to a File / Reading From and Writing to a File/File Handle.
7. Append the following string of data to the list
- *Hint*: recordsList.append
8. Open a new csv file for writing. Name this file
- *Reference*: Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 9: Defining a Path to a File / Reading From and Writing to a File / File Handle.
9. Write a record to the file that contains the following values that will serve as the header record in your csv file:
- `Customer ID, Last Name, First Name, Address, City, State, Promo Credit`
- *Hint*: add `\n` to the end of this string to force a new line.
- *Reference*: Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 9: Defining a Path to a File / Reading From and Writing to a File / File Handle.
10. Use another for loop to process the list data.
- With each iteration through the loop, write out a record.
- Append the promotional credit.
- *Hint*: This can be done by simply adding the value in a string like file.write(". Don’t forget the newline character at the end.
- Increment the record count variable.
11. Close the file.
12. Conclude the program by printing a statement that includes the record count: