Traitement-signal-plantes/Code-C/fileGestion.c
2022-06-02 14:29:21 +02:00

27 lines
708 B
C

#include "fileGestion.h"
void clearRawData(int N){
char buffer[256];
FILE *f = fopen("newFile.csv","w+");
FILE *g = fopen("rawData.csv","r");
for(int i = 0; i < N; i++){
fgets(buffer , sizeof buffer , g);
//printf("Line contaigns: %s" , buffer);
}
while(1){
if(!fgets(buffer,sizeof buffer , g)) break;
fprintf(f,"%s",buffer);
}
remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
}
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]);
}
}
}