creating file name from column data
Sep 16, 2013 at 4:21pm UTC
I have 3 files like this
file 1: ID.txt (43000 row data, one column)
file 2: MORECS.txt (201 row data, one column)
file 3: is the input for 201 files located in the folder cumulative.
my problem is:
when the row data in file 2 is 1 it should open file 1 from the cumulative folder and copy the entire file and store as the first row number of file 1 and so on. I have made the code like this, but it is not working!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include<iostream>
#include<fstream>
#include<string>
#include<direct.h>
#include<sstream>
using namespace std;
void main()
{
int d,m,y,ju;
float min, max, ppt;
float dummy;
string Array[10];
string Morecs[10];
ifstream myfile ("ID.txt" );
ifstream more ("morecs.txt" );
for (int i = 0; i < 10; i++)
{
getline (more,Morecs[i]);
stringstream weather;
weather<<"cumulative" <<"/" <<"MORECS_GRID_" <<Morecs[i]<<".wth" ;
string weatherfile = weather.str();
ifstream morecsgrid(weatherfile);
for (int j = 0; j< 10; j++)
{
getline (myfile,Array[j]);
stringstream oo;
oo <<"weather_" << Array[j] <<".wth" << endl;
string outfile=oo.str();
ofstream weather_ID(outfile);
cout<<outfile;
while (morecsgrid>>d>>m>>y>>ju>>min>>max>>ppt>>dummy>>dummy>>dummy>>dummy>>dummy)
{
weather_ID<<d<<'\t' <<m<<'\t' <<y<<'\t' <<ju<<'\t' <<max<<'\t' <<min<<'\t' <<ppt<<" " <<dummy<<'\t' <<dummy<<'\t' <<dummy<<'\t' <<dummy<<'\t' <<dummy<<endl;
}
cout<<weatherfile;
}
}
system("pause" );
}
Topic archived. No new replies allowed.