re !!
donc j'ai essayer ce que tu me propose :
ecriture:
extrait de mon fichier txt :
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:34 2024
23.438, 23.375, 23.625, 23.000, 23.500, Thu Mar 7 16:54:35 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:36 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:37 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:38 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:39 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:40 2024
et des que je lance mon programme lecture :
le probleme apparait et j'ai donc dans mon fichier txt:
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:40 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:41 2024
-1352.375, -9999.900, 23.625, -9999.900, -9999.900, Thu Mar 7 16:54:42 2024
23.438, -9999.900, 23.625, -9999.900, 23.562, Thu Mar 7 16:54:45 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:47 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:48 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:49 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:50 2024
donc j'ai essayer ce que tu me propose :
ecriture:
Code:
void ecritTemps () { FILE * nomFich; float t0 = ds_temperature[0]; float t1 = ds_temperature[1]; float t2 = ds_temperature[2]; float t3 = ds_temperature[3]; float t4 = ds_temperature[4]; nomFich = fopen ("temperaturesLue.txt", "at"); // append : ecrit a la suite if (nomFich == NULL) { cout << "Impossible d'ouvrir le fichier en ecriture !" << endl; exit (77); // on s'arrete car il y a un gros problème } else { fprintf (nomFich, "%2.3f, %8.3f, %8.3f, %8.3f, %8.3f, %s \r\n", t0, t1, t2, t3, t4, ctime ( & rawtime)); fclose (nomFich); // on ferme le plus vite possible, que l'on puisse lire à tout moment... cout << t0 << ", " << t1 << ", " << t2 << ", " << t3 << ", " << t4 << ", " << ctime ( & rawtime) << endl; cout << "Ecriture Ok !" << endl << endl; }}
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:34 2024
23.438, 23.375, 23.625, 23.000, 23.500, Thu Mar 7 16:54:35 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:36 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:37 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:38 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:39 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:40 2024
et des que je lance mon programme lecture :
Code:
void lectureTemps () { FILE * nomFich = fopen ("/home/ludo/gpiod_cpp/testFichier/ecrit/temperaturesLue.txt", "rt"); if (nomFich == NULL) { cout << "Impossible d'ouvrir le fichier en lecture !" << endl; exit (78); } else { float t0;// = {-9999.9}; float t1;// = {-9999.9}; float t2;// = {-9999.9}; float t3;// = {-9999.9}; float t4;// = {-9999.9}; int nbChamp = {fscanf (nomFich, "%f, %f, %f, %f, %f, %s", &t0, &t1, &t2, &t3, &t4, ctime ( & rawtime))}; if (nbChamp < 6) { cout << "erreur decodage" << endl; exit (79); } else { fclose(nomFich); cout << "lecture ok !" << endl; cout << t0 << ", " << t1 << ", " << t2 << ", " << t3 << ", " << t4 << ", " << ctime ( & rawtime) << endl; tempExtLue = t0; tempUnitExtLue = t1; tempEcExtLue = t2; tempUnitIntLue = t3; tempEcIntLue = t4; } }}
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:40 2024
23.500, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:41 2024
-1352.375, -9999.900, 23.625, -9999.900, -9999.900, Thu Mar 7 16:54:42 2024
23.438, -9999.900, 23.625, -9999.900, 23.562, Thu Mar 7 16:54:45 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:47 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:48 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:49 2024
23.438, 23.375, 23.625, 23.000, 23.562, Thu Mar 7 16:54:50 2024
Statistics: Posted by ludoraspberry — Thu Mar 07, 2024 4:00 pm