Question

I can't get the program to read from prospect.csv file and produce the correct prospect_clean.csv file....

I can't get the program to read from prospect.csv file and produce the correct prospect_clean.csv file. Can you help with explanation to the answer?

Project 15-3: File Cleaner

Create an application that reads a file that contains an email list, reformats the data, and writes the cleaned list to another file.

Console

File Cleaner

Source file:  prospects.csv

Cleaned file: prospects_clean.csv

Congratulations! Your file has been cleaned!

The prospect.csv file

FIRST,LAST,EMAIL

james,butler,jbutler@gail.com

Josephine,Darakjy,josephine_darakjy@darakjy.org

ART,VENERE,ART@VENERE.ORG

...

The prospect_clean.csv file

First,Last,email

James,Butler,jbutler@gail.com

Josephine,Darakjy,josephine_darakjy@darakjy.org

Art,Venere,art@venere.org

...

Specifications

Your instructor should provide a CSV file named prospects.csv that contains a list of prospects.

Your application should fix the formatting problems and write a file named prospects_clean.csv.

All names should use title case (an initial capital letter with the rest lowercase).

All email addresses should be lowercase.

All extra spaces at the start or end of a string should be removed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<ctype.h>
int main(int argc, char **argv)
{
   int i,space_count,column_count,letter_position,line_count;
   char container,pre_container;
   FILE *input,*output;

  
   pre_container = 'a';
   input=fopen("prospects.csv","r");
   if(input == NULL)
   {
       printf("\n\t Error in reading file\n");
       return 1;
   }  

   output=fopen("prospects_clean.csv","w");
   if(output == NULL)
   {
       printf("\n\t Error in writing file\n");
       return 1;
   }  
  
   space_count=0;
   column_count=1;
   letter_position=0;
   line_count = 0;
   fscanf(input,"%c",&container);
   while(container != EOF)
   {
       if((container==' ')||(container=='\t'))
       {
           space_count++;
           line_count=0;
       }
       else if(container ==',')
       {
           space_count = 0;
           column_count++;
           letter_position = 0;
           line_count = 0;
           fprintf(output,",");
       }
       else if(container=='\n')
       {
           space_count = 0;
           column_count = 1;
           letter_position = 0;
           line_count++;
       /*   As end of file differ in each operating system. In my PC, at the end of file I get newline character in scanning */
           if((line_count >= 3)||(pre_container == '\r'))
           {
               fprintf(output,"\r\n");
               break;
           }
           else if(line_count == 1)
               fprintf(output,"\n");
           else
               ;
       }
      
       else if((letter_position==0) && (column_count != 3))
       {
           space_count = 0;
           line_count = 0;
           if(islower(container))
               fprintf(output,"%c",toupper(container));
           else  
               fprintf(output,"%c",container);
           letter_position ++;
       }
       else
       {
           line_count = 0;
           for(i=0;i<space_count;i++)
           {
               fprintf(output," ");
           }
           space_count=0;
           if(isupper(container))
               fprintf(output,"%c",tolower(container));
           else  
               fprintf(output,"%c",container);
           letter_position ++;
       }

      
       pre_container = container;
       fscanf(input,"%c",&container);  
   }
   fclose(input);
   fclose(output);
   printf("\n\tCongratulations! Your file has been cleaned!\n");  
   return 0;
}

==================================================================

==================================================================

==================================================================

prospect.csv

==================================================================

prospect_clean.csv

Add a comment
Know the answer?
Add Answer to:
I can't get the program to read from prospect.csv file and produce the correct prospect_clean.csv file....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this Java question. Please only answer in Java. Also, please answer it...

    I need help with this Java question. Please only answer in Java. Also, please answer it as simple as possible thanks. Create an application that reads a file that contains an email list, reformats the data, and writes the cleaned list to another file. Console File Cleaner Source file:  prospects.csv Cleaned file: prospects_clean.csv Congratulations! Your file has been cleaned! The prospect.csv file FIRST,LAST,EMAIL james,butler,jbutler@random.com Josephine,Darakjy,josephine_darakjy@darakjy.org ART,VENERE,ART@VENERE.ORG The prospect_clean.csv file First,Last,email James,Butler,jbutler@random.com Josephine,Darakjy,josephine_darakjy@darakjy.org Art,Venere,art@venere.org Specifications Your instructor should provide a CSV file...

  • Hello can somebody please help me with Project 15-3 File Cleaner assignment? This project is to...

    Hello can somebody please help me with Project 15-3 File Cleaner assignment? This project is to be done while using Java programming. Here are what the assignment says… Create an application that reads a file that contains an email list, reformats the data, and writes the cleaned list to another file. Below are the grading criteria… Fix formatting. The application should fix the formatting problems. Write the File. Your application should write a file named prospects_clean.csv. Use title case. All...

  • Java Email Template Application: Create an application that creates a series of emails as outlined below....

    Java Email Template Application: Create an application that creates a series of emails as outlined below. Create an array of email addresses that include the following data: "   james   ,butler,jbutler@hotmail.com" "Josephine,Darakjy,Josephine_Darakjy@darakjy.org" "ART,VENERE,ART@VENERE.ORG" Store a template for a mass email like this: String template =     "To:      {email}\n" +     "From:    noreply@deals.com\n" +     "Subject: Deals!\n\n" +     "Hi {first_name},\n\n" +     "We've got some great deals for you. Check our website!"; When the application starts, it should read the email...

  • In C++ please! Project 6-1: Email Creator Create a program that reads a file and creates...

    In C++ please! Project 6-1: Email Creator Create a program that reads a file and creates a series of emails Console Email Creator jbutler@gmail.com noreply@deals.com Тo: From: Subject: Deals! Hi James, We've got some great deals for you. Check our website! josephine_darakjy@darakjy.org noreply@deals.com To From Subject: Deals! Hi Josephine, We've got some great deals for you. Check our website! art@venere.org To From noreply@deals.com Subject: Deals! Hi Art We've got some great deals for you. Check our website! Specifications Your instructor...

  • Create a program that will use the attached input file and perform the following operations. Read...

    Create a program that will use the attached input file and perform the following operations. Read the file into an appropriate JCF data structure. Look up a (list of) names and numbers matching a last name or the first letters of a last name, ignoring case. Look up a (list of) names and numbers matching a number or the first digits of a number. Add a name and number to the list. Sort the list by first name, last name...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT