Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>
- #include <vector>
- using namespace std;
- std::vector<std::string> split(const std::string& s, char seperator)
- {
- vector<std::string> output;
- std::string::size_type prev_pos = 0, pos = 0;
- while ((pos = s.find(seperator, pos)) != std::string::npos)
- {
- std::string substring(s.substr(prev_pos, pos - prev_pos));
- if (substring != "")
- {
- output.push_back(substring);
- }
- prev_pos = ++pos;
- }
- output.push_back(s.substr(prev_pos, pos - prev_pos)); // Last word
- return output;
- }
- int main()
- {
- ifstream in;
- ofstream out;
- in.open("E:/out");
- out.open("E:/in");
- auto molId = 0;
- while (!in.eof())
- {
- int cnt;
- string comment;
- in >> cnt;
- getline(in, comment);
- getline(in, comment);
- auto isp = split(comment, ',');
- auto fst = split(isp[0], '-');
- auto l = std::to_string(molId) + ";" + fst[0] + ";" + fst[1] + ";" + fst[4] + ";" + fst[6] + ";" + isp[1] + ";" + isp[2] + ";" + isp[3];
- for (auto i = 0; i < cnt; i++)
- {
- string line;
- string clean;
- getline(in, line);
- clean = "";
- auto fmt = split(line, ' ');
- for (auto it = fmt.begin(); it != fmt.end(); it++)
- {
- clean += *it + ";";
- }
- out << l << clean;
- }
- molId++;
- }
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement