Advertisement
Guest User

Untitled

a guest
May 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #include <algorithm>
  2. #include <ctime>
  3. #include <fstream>
  4. #include <iomanip>
  5. #include <iostream>
  6. #include <iterator>
  7. #include <vector>
  8. #include <numeric>
  9. #include <sstream>
  10. #include <stdint.h>
  11.  
  12. using namespace std;
  13.  
  14.  
  15. int main(int ac, char **av) {
  16.  
  17.  
  18. string file_name = "col2.txt";
  19. std::fstream f(file_name, std::ios_base::in | ios::binary);
  20. uint64_t key;
  21. file_name = "col6.txt";
  22. std::fstream f1(file_name, std::ios_base::in | ios::binary);
  23. file_name = "col1.txt";
  24. std::fstream f4(file_name, std::ios_base::in | ios::binary);
  25. string date_string;
  26. file_name = "col5.txt";
  27. std::fstream f2(file_name, std::ios_base::in | ios::binary);
  28. char bool_char;
  29. unsigned int myenum;
  30. file_name = "col7.txt";
  31. std::fstream f7(file_name, std::ios_base::in | ios::binary);
  32. file_name = "col1.bin";
  33. std::ofstream f1_out(file_name, std::ios_base::out | ios::binary);
  34. file_name = "col2.bin";
  35. std::ofstream f2_out(file_name, std::ios_base::out | ios::binary);
  36. file_name = "col3.bin";
  37. std::ofstream f3_out(file_name, std::ios_base::out | ios::binary);
  38. file_name = "col5.bin";
  39. std::ofstream f5_out(file_name, std::ios_base::out | ios::binary);
  40. file_name = "col6.bin";
  41. std::ofstream f6_out(file_name, std::ios_base::out | ios::binary);
  42. file_name = "col7.bin";
  43. std::ofstream f7_out(file_name, std::ios_base::out | ios::binary);
  44.  
  45.  
  46. cout << "Parsing columns " << endl;
  47.  
  48. if (f) {
  49. while (f >> key) {
  50. f2_out.write(reinterpret_cast<const char *>(&key), 8);
  51. };
  52. f2_out.close();
  53. }
  54. else {
  55. cout << "Could not open file " << file_name << endl;
  56. exit(0);
  57. };
  58.  
  59. if (f4) {
  60. while (f4 >> key) {
  61. f1_out.write(reinterpret_cast<const char *>(&key), 8);
  62. };
  63. f1_out.close();
  64. }
  65. else {
  66. cout << "Could not open file " << file_name << endl;
  67. exit(0);
  68. };
  69.  
  70.  
  71. if (f1) {
  72. unsigned int mydate;
  73. while (f1 >> date_string) {
  74. mydate = std::stoi(date_string.substr(0, 4) +
  75. date_string.substr(5, 2) +
  76. date_string.substr(8, 2));
  77. f6_out.write(reinterpret_cast<const char *>(&mydate), 4);
  78. };
  79. f6_out.close();
  80. }
  81. else {
  82. cout << "Could not open file " << file_name << endl;
  83. exit(0);
  84. };
  85.  
  86. if (f2) {
  87. while (f2 >> bool_char) {
  88. f5_out.write(reinterpret_cast<const char *>(&bool_char), 1);
  89. };
  90. f5_out.close();
  91. }
  92. else {
  93. cout << "Could not open file " << file_name << endl;
  94. exit(0);
  95. };
  96.  
  97. if (f7) {
  98. while (f7 >> myenum) {
  99. f7_out.write(reinterpret_cast<const char *>(&myenum), 4);
  100. };
  101. f7_out.close();
  102. }
  103. else {
  104. cout << "Could not open file " << file_name << endl;
  105. exit(0);
  106. };
  107.  
  108.  
  109. return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement