Answered step by step
Verified Expert Solution
Link Copied!

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 1, Number 2, Number 3
1,2,3
4,5,6
7,8,9
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 -1.
Would be translated to a CSV file as:
1,2
3,4
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 check-off 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 1:
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 2:
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 3:
Writing into a CSV file. Must show:
A successfully created CSV file
All items on one row, but multiple columns
Milestone 4:
Properly formatting the CSv file. Must show:
-1 is not added to the file
Where -1 would be, there is instead a new row
There is NO floating comma at the end of each row
Milestone 5:
Works with multiple files. Show milestone 5 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
-1
Oreo
-1
Maggie
Appollo
Nubs
-1
testing.txt
1
2
3
-1
4
5
6
-1
7
8
9
-1
10
11
12
-1
Books:
Title
Author
Year Released
Genre
-1
The Color Purple
Alice Walker
1982
Epistolary
-1
The Road
Cormac McCarthy
2006
Post Apocalyptic fiction
-1
To Kill a Mockingbird
Harper Lee
1960
Southern Gothic
-1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

b. Will new members be welcomed?

Answered: 1 week ago