Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <ctime>
- #include <fstream>
- #include <iomanip>
- #include <iostream>
- #include <iterator>
- #include <vector>
- #include <numeric>
- #include <sstream>
- #include <stdint.h>
- using namespace std;
- int main(int ac, char **av) {
- string file_name = "col2.txt";
- std::fstream f(file_name, std::ios_base::in | ios::binary);
- uint64_t key;
- file_name = "col6.txt";
- std::fstream f1(file_name, std::ios_base::in | ios::binary);
- file_name = "col1.txt";
- std::fstream f4(file_name, std::ios_base::in | ios::binary);
- string date_string;
- file_name = "col5.txt";
- std::fstream f2(file_name, std::ios_base::in | ios::binary);
- char bool_char;
- unsigned int myenum;
- file_name = "col7.txt";
- std::fstream f7(file_name, std::ios_base::in | ios::binary);
- file_name = "col1.bin";
- std::ofstream f1_out(file_name, std::ios_base::out | ios::binary);
- file_name = "col2.bin";
- std::ofstream f2_out(file_name, std::ios_base::out | ios::binary);
- file_name = "col3.bin";
- std::ofstream f3_out(file_name, std::ios_base::out | ios::binary);
- file_name = "col5.bin";
- std::ofstream f5_out(file_name, std::ios_base::out | ios::binary);
- file_name = "col6.bin";
- std::ofstream f6_out(file_name, std::ios_base::out | ios::binary);
- file_name = "col7.bin";
- std::ofstream f7_out(file_name, std::ios_base::out | ios::binary);
- cout << "Parsing columns " << endl;
- if (f) {
- while (f >> key) {
- f2_out.write(reinterpret_cast<const char *>(&key), 8);
- };
- f2_out.close();
- }
- else {
- cout << "Could not open file " << file_name << endl;
- exit(0);
- };
- if (f4) {
- while (f4 >> key) {
- f1_out.write(reinterpret_cast<const char *>(&key), 8);
- };
- f1_out.close();
- }
- else {
- cout << "Could not open file " << file_name << endl;
- exit(0);
- };
- if (f1) {
- unsigned int mydate;
- while (f1 >> date_string) {
- mydate = std::stoi(date_string.substr(0, 4) +
- date_string.substr(5, 2) +
- date_string.substr(8, 2));
- f6_out.write(reinterpret_cast<const char *>(&mydate), 4);
- };
- f6_out.close();
- }
- else {
- cout << "Could not open file " << file_name << endl;
- exit(0);
- };
- if (f2) {
- while (f2 >> bool_char) {
- f5_out.write(reinterpret_cast<const char *>(&bool_char), 1);
- };
- f5_out.close();
- }
- else {
- cout << "Could not open file " << file_name << endl;
- exit(0);
- };
- if (f7) {
- while (f7 >> myenum) {
- f7_out.write(reinterpret_cast<const char *>(&myenum), 4);
- };
- f7_out.close();
- }
- else {
- cout << "Could not open file " << file_name << endl;
- exit(0);
- };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement