Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives: Continue practicing past concepts Practice using files Practice using vectors Background: Comma separated vector ( CSV ) files are a type of text file
Objectives:
Continue practicing past concepts
Practice using files
Practice using vectors
Background:
Comma separated vector CSV files are a type of text file specifically using the csv file
extension These can be viewed in any plain text editor, but they can also be represented in
spreadsheet programs ie Excel Essentially, it defines columns by commas on each line.
Where each row is then actually a row in a table.
Their plain text version looks something like this:
Number Number Number
Whereas, if you'd show the same file in Excel, it'd look like this:
Assignment:
Your job is to create a program that takes in a standard text txt file and converts that to a CSV
csv file. Each item will be designated by an individual item in a row in the text file. Then, we'll
define when you should have a new row in the CSV file by an exit character
Would be translated to a CSV file as:
Your program should, take in a base filename WITHOUT AN EXTENSION open that filename
with txt added and verify the existence in a loop. Once you have a valid file, read the contents
into a vector and close the input file. Then, open an output file of the input filename with csv
added and write the contents of the vector appropriately.
Your program should end with the following files existing:
filename, txt
filename.csv
A couple sample text files have been provided to use.
Milestones:
You must receive a checkoff for each item to receive full credit on the lab. You may show the
milestones incrementally, or receive a check off for multiple in one demo depending on your
progress.
Examples of each milestone are included.
Milestone :
Take user input for the file without an extension. Loop until the file exists. Must show:
Looping until a file that exists is entered
No extension is taken from the user
Milestone :
Read the contents of your file into a vector. Must show:
File contents printed to the screen FROM A VECTOR
To get checked off for this one, you must show in the demo, a vector is being read from
to display to the screen, not printing to the screen as you're reading the file
Milestone :
Writing into a CSV file. Must show:
A successfully created CSV file
All items on one row, but multiple columns
Milestone :
Properly formatting the CSv file. Must show:
is not added to the file
Where would be there is instead a new row
There is NO floating comma at the end of each row
Milestone :
Works with multiple files. Show milestone with all sample files provided to you. Must show:
Ran FRESHLY Cannot have prepared files to show all at once these must be generated by the program, in real time.
Sample Files:
pets.txt:
Ghost
Min
Max
Coco
Oreo
Maggie
Appollo
Nubs
testing.txt
Books:
Title
Author
Year Released
Genre
The Color Purple
Alice Walker
Epistolary
The Road
Cormac McCarthy
Post Apocalyptic fiction
To Kill a Mockingbird
Harper Lee
Southern Gothic
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started