Guest User

Untitled

a guest
Mar 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. const char* getfield(char* line, int num){
  5. const char* tok;
  6. for (tok = strtok(line, ","); tok && *tok ; tok = strtok(NULL, ",n")){
  7. if (!--num){
  8. return tok;
  9. }
  10. }
  11. return NULL;
  12. }
  13. int main(){
  14. FILE* stream = fopen("perf log (paralel encoding disabled).CSV", "r");
  15. FILE *f = fopen("file2.html", "w+");
  16. if (f == NULL){
  17. printf("Error opening file!n");
  18. exit(1);
  19. }
  20. 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";
  21. fprintf(f, "%s", html1 );
  22. int i = 0;
  23. char line1[102400];
  24. while (fgets(line1, 102400, stream)){
  25. char* tmp1 = strdup(line1);
  26. if(i > -1 && i<60000){
  27. fprintf(f,"[%i , %s , %s , %s ] <br>",i, getfield(tmp1, 1), getfield(tmp1, 2), getfield(tmp1, 3), );
  28. }
  29. free(tmp1);
  30. i++;
  31. }
  32. char* html4 = " n </body> n </html> n";
  33. fprintf(f, "%s", html4);
  34. fclose(f);
  35. }
  36.  
  37. [0 , Date , (null) , "Virtual Memory Commited [MB]" ]
  38. [1 , 13.3.2018 , (null) , 7226 ]
  39. [2 , 13.3.2018 , (null) , 7237 ]
  40. [3 , 13.3.2018 , (null) , 7226 ]
  41. [4 , 13.3.2018 , (null) , 7298 ]
  42. [5 , 13.3.2018 , (null) , 8011 ]
Add Comment
Please, Sign In to add comment