Traitement-signal-plantes/Code-C/fileGestion.c

27 lines
708 B
C
Raw Normal View History

2022-06-01 12:32:04 +02:00
#include "fileGestion.h"
2022-06-01 17:01:23 +02:00
void clearRawData(int N){
2022-06-01 12:32:04 +02:00
char buffer[256];
2022-06-02 14:29:21 +02:00
FILE *f = fopen("newFile.csv","w+");
FILE *g = fopen("rawData.csv","r");
2022-06-01 17:01:23 +02:00
for(int i = 0; i < N; i++){
fgets(buffer , sizeof buffer , g);
2022-06-01 12:32:04 +02:00
//printf("Line contaigns: %s" , buffer);
}
while(1){
2022-06-01 17:01:23 +02:00
if(!fgets(buffer,sizeof buffer , g)) break;
2022-06-01 12:32:04 +02:00
fprintf(f,"%s",buffer);
}
2022-06-02 14:29:21 +02:00
remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
2022-06-01 12:32:04 +02:00
}
2022-06-02 14:29:21 +02:00
void writePowerData(double a[], int N){
FILE *f = fopen("powerData.csv","a+");
for(int i = 0 ; i < N ; i++){
if( i < N-1){
fprintf(f, "%f , ", a[i]);
} else {
fprintf(f, "%f\n", a[i]);
}
}
}