Question: C program code: #include / / #define SIZE 5 0 0 int main ( ) { char CSV = ' , ' ; puts (

C program code:
#include
//#define SIZE 500
int main()
{
char CSV =',';
puts("Time\t\t\t Magnitude\t\t Place");
//printf("%-30s %-11s %-8s %s
", "Time", "magnitude", "Place");
FILE *fp=fopen("data.csv","r");
int ch = getc(fp);
while(ch !=EOF){
putchar(ch);
ch = getc(fp);
}
if (feof(fp))
printf("
End of file reached.");
else
printf("
Something went wrong.");
printf("
Press [Enter] to exit");
getchar();
return 0;
}
I have a large CSV file.
time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type,horizontalError,depthError,magError,magNst,status,locationSource,magSource
2024-04-10T14:56:17.086Z,42.0113,82.6416,6.451,5.4,mww,169,19,2.674,0.69,us,us7000mb76,2024-04-11T15:10:18.259Z,"40 km NW of Kuqa, China",earthquake,7.08,4.064,0.083,14,reviewed,us,us
2024-04-09T09:48:01.680Z,2.7135,127.0944,35,6.6,mww,139,23,1.948,0.71,us,us7000maxr,2024-04-10T09:54:41.562Z,"149 km NW of Tobelo, Indonesia",earthquake,6.64,1.876,0.059,28,reviewed,us,us
1- I need to extract and printout this column, (time, mag, place)
2- I need to add another column to these three-column named (cost)
3- Calculate/display cost column using the following formula: Magnitude*1000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!