Question
Write a program in C program Continuing from the previous chapter, you now have a beautiful txt file, but the txt file is too low,
Write a program in C program
Continuing from the previous chapter, you now have a beautiful txt file, but the txt file is too low, so you need to make it into a CSV file. (25%)
Here are the CSV specifications you need to be aware of:
CSV is a delimited data format that has fields/columns separated by comma characters and records/rows terminated by newlines.
example:
The above data table can be expressed in CSV format as follows:
Rank,Name,Score1,Score2,Score3,Total
1,UsaMegami,100,100,100,100.0
2,UsadaPekora,70,77,65,70.1
3,TodorokiHajime,76,44,60,60.0
4,Mio,56,78,45,58.2
5,SakamataChloe,10,0,5,5.0
Enter description:
Enter a string representing the file name. The file name must be less than 20 characters. Assume that the input is in.txt.
The data format stored in the in.txt file is as follows
Use the data in in.txt as subsequent input and read to EOF.
Output description:
Write the input into out.csv in csv format
After writing, use the following code to output the contents of out.csv. (Copy and paste this paragraph to the end of your main function, before return 0)
Example input:
in1_1.txt
Sample file in1_1.txt: (data stored in in1_1.txt)
Rank Name Score1 Score2 Score3 Total
1 UsaMegami 100 100 100 100.0
2 UsadaPekora 70 77 65 70.1
3 TodorokiHajime 76 44 60 60.0
4 Mio 56 78 45 58.2
5 SakamataChloe 10 0 5 5.0
Sample output: (data stored in out.csv)
Rank,Name,Score1,Score2,Score3,Total
1,UsaMegami,100,100,100,100.0
2,UsadaPekora,70,77,65,70.1
3,TodorokiHajime,76,44,60,60.0
4,Mio,56,78,45,58.2
5,SakamataChloe,10,0,5,5.0
Example description:
out.csv looks like this
: 1. , txt, txtlow, CSV(25\%) CSV: CSV, // : CSV: Rank,Name,Score1,Score2,Score3,Total 1,UsaMegami,100,100,100,100.0 2,UsadaPekora, 70,77,65,70.1 3,TodorokiHajime,76,44,60,60.0 4, Mio, 56,78,45,58.2 5,SakamataChloe, 10,0,5,5.0 : , 20, in.txt in.txt Rank Name Score1 Score2 Score3 Total RankName1NameScore117 , Score1Score2Score31Score3Total23 42061 in.txt, EOF : csvout.csv out.csv(main, return 0 ) FILE *CHECK_FILE; char CheckCh; CHECK_FILE =fopen("out.csv","r"); while((CheckCh =getc(CHECK_FILE))!=EOF) putchar(CheckCh); fclose(CHECK_FILE); : (out.csv) Rank,Name,Score1,Score2,Score3,Total 1,UsaMegami,100,100,100,100.0 2,UsadaPekora, 70,77,65,70.1 3,TodorokiHajime, 76,44,60,60.0 4,Mio,56,78,45,58.2 5,SakamataChloe, 10,0,5,5.0 : out.csv C:\Users\User\Desktop \bhw13\7111056150_p1.exe in 1 1.txt Rank, Name, Score1,Score2,Score3, Total 1 , Usallegani 1, 100,100,100,100.0 , UsadaPekora, 70,77,65,70.1 ,Todorok iHaj ime, 76,44,60,60.0 4, ,Hio, 56, 78, 45, 58.2 5, SakamataCh loe, 10,0,5,5.0 Process exited after 1.185 seconds with return value 0 FILE *CHECK_FILE; char CheckCh; CHECK_FILE =fopen("out.csv","r"); while((CheckCh =getc(CHECK_FILE))!=EOF) putchar(CheckCh); fclose(CHECK_FILE); \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|} \hline \\ \hline & & & & & & \multirow{2}{*}{\begin{tabular}{c} \\ A \end{tabular}} \\ \hline & & & & \multicolumn{2}{|c|}{ } & & v12v & AA & \\ \hline & & & & B 1 & IU= & & A v & | & \\ \hline & & & y & & & & & & a \\ \hline (i) & & & & & & (.cs & sv) & & \\ \hline A1 & & & & x & fx & Rank & & & \\ \hline 4 & & & & B & C & D & E & & F \\ \hline 1 & Rank & & Nam & & Scorel & Score2 & Score 3 & & Total \\ \hline 2 & & & Usal & legam & 100 & 100 & & 100 & 100 \\ \hline 3 & & & Usad & aPeko & 70 & 77 & & 65 & 70.1 \\ \hline 4 & & & Todo & rokiH & 76 & 44 & & 60 & 60 \\ \hline 5 & & & Mio & & 56 & 78 & & 45 & 58.2 \\ \hline 6 & & 5 & Saka & mataC & 10 & 0 & & 5 & 5 \\ \hline \end{tabular} C: \ Users \ User \ Desktop \bhw13\7111056150_p1.exe in 1 1.t.t. Rank, Name, Score1,Score2,Score3, Total 1 , Usakegami i, 100, 100, 100,100.0 2 , UsadaPekora, 70,77,65,70.1 3,TodorokiHaj ime, 76,44,60,60.0 4,Hio,56,78,45,58.2 5,SakamataCh loe, 10,0,5,5.0 Process exited after 1.185 seconds with return value 0
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