Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- const char* getfield(char* line, int num){
- const char* tok;
- for (tok = strtok(line, ","); tok && *tok ; tok = strtok(NULL, ",n")){
- if (!--num){
- return tok;
- }
- }
- return NULL;
- }
- int main(){
- FILE* stream = fopen("perf log (paralel encoding disabled).CSV", "r");
- FILE *f = fopen("file2.html", "w+");
- if (f == NULL){
- printf("Error opening file!n");
- exit(1);
- }
- char* html1 = "<!DOCTYPE html> n<html> n<head> n <title></title> n</head> n<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'> </script>n <body> n";
- fprintf(f, "%s", html1 );
- int i = 0;
- char line1[102400];
- while (fgets(line1, 102400, stream)){
- char* tmp1 = strdup(line1);
- if(i > -1 && i<60000){
- fprintf(f,"[%i , %s , %s , %s ] <br>",i, getfield(tmp1, 1), getfield(tmp1, 2), getfield(tmp1, 3), );
- }
- free(tmp1);
- i++;
- }
- char* html4 = " n </body> n </html> n";
- fprintf(f, "%s", html4);
- fclose(f);
- }
- [0 , Date , (null) , "Virtual Memory Commited [MB]" ]
- [1 , 13.3.2018 , (null) , 7226 ]
- [2 , 13.3.2018 , (null) , 7237 ]
- [3 , 13.3.2018 , (null) , 7226 ]
- [4 , 13.3.2018 , (null) , 7298 ]
- [5 , 13.3.2018 , (null) , 8011 ]
Add Comment
Please, Sign In to add comment