Improve parsing util
This commit is contained in:
parent
8cebe37466
commit
17b79f3d8d
1 changed files with 15 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Compile: cc -O2 -luuid parse.c -o parse
|
||||||
|
* Usage: ./parse 7500 a.bin b.bin
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -11,18 +16,24 @@ int cmpuint64t(const void* u1, const void* u2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc < 3) {
|
||||||
|
printf("Usage: %s <count> <filepath>+\n", argv[0]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
FILE *r, *w;
|
FILE *r, *w;
|
||||||
uint64_t taglen;
|
uint64_t taglen;
|
||||||
char tag[255];
|
char tag[255], filename[255];
|
||||||
uuid_t uuid;
|
uuid_t uuid;
|
||||||
char uuidstr[37];
|
char uuidstr[37];
|
||||||
uint64_t meascount;
|
uint64_t meascount;
|
||||||
uint64_t meas[25*60*90]; /* can contain up to ninety minutes of meas */
|
uint64_t meas[25*60*90]; /* can contain up to ninety minutes of meas */
|
||||||
uint64_t target = 25*60*5; /* five minutes of measures*/
|
uint64_t target = atoi(argv[1]); /* subset of measures to consider */
|
||||||
|
|
||||||
if ((w = fopen("5min.csv", "w")) == NULL) goto iofail;
|
sprintf(filename, "%d.csv", target);
|
||||||
|
if ((w = fopen(filename, "w")) == NULL) goto iofail;
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 2; i < argc; i++) {
|
||||||
printf("selected %s\n", argv[i]);
|
printf("selected %s\n", argv[i]);
|
||||||
if ((r = fopen(argv[i], "r")) == NULL) goto iofail;
|
if ((r = fopen(argv[i], "r")) == NULL) goto iofail;
|
||||||
if (fread(&taglen, sizeof(taglen), 1, r) != 1) goto iofail;
|
if (fread(&taglen, sizeof(taglen), 1, r) != 1) goto iofail;
|
Loading…
Reference in a new issue