Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OpenFile(){
- ifstream MyReadFile;
- MyReadFile.open("..\\vstupnidata\\Hodiny.csv");
- string currentline;
- int CountEmployee = CountRow(MyReadFile);
- Vyplata Tabulka[CountEmployee];
- HTML_File Finally[CountEmployee];
- int c = 0;
- double * Array = new double[c];
- bool x = true;
- bool y = false;
- cout << CountEmployee << endl;
- if (!MyReadFile.is_open())
- {
- cout << "Chyba pri otevreni souboru." << endl;
- MyReadFile.close();
- }
- while(!MyReadFile.eof())
- {
- //trosku jsem upravila to csv....
- //Lucy K.;90;8:00,8:00,8:00,8:30,8:30,7:30,9:30,5:00,6:00,6:30,8:30;
- //Anton B.;100;8:00,8:00,8:00,8:00,5:30,8:00,8:00,8:00,5:30,8:00,8:00,8:30,7:30,9:30;
- //Mary S.;85;8:30,8:00,8:00,8:30,8:30,8:00,8:30,6:00,6:30;
- //Dens U.;100;8:00,8:00,8:30,8:00,8:30,8:30;
- //Marie. N.;95;8:00,8:00,8:00,8:00,8:00,8:30,7:30,8:00,8:30,6:00;
- //kdyz zavolas getline a nespecifikujes tam oddelovac (tady ';'), tak program precte cely prvni radek a kdyz narazi na
- //konec radku('\n'),presune se na druhy a ceka.
- //to se tam stalo tobe - ty jsi nejdriv kontroloval tohle:
- //while(getline(MyReadFile, currentline)) .... ale tim uz jsi tu funkci getline zavolal a program byl presunuty na druhy radek
- //a dalsim zavolanim getlinu, kde jsi chtel teprv nacitat data, precetl znaky od zacatku druheho radku
- //po ten oddelovac, co jsi mel nastaveny
- //tady v tom porad kontrolujes, jestli ten dalsi radek existuje, ale prectes jenom znaky po oddelovac a rovnou to ukladas
- //do tabulky - neukladas tak nejdriv cely radek do currentline, coz stejne nepotrebujes, ale rovnou tim i ulozis data co
- //chces, a v tele whilu doukladas ten zbytek
- while(getline(MyReadFile, Tabulka[c].Name, ';'))
- {
- getline(MyReadFile, Tabulka[c].Income, ';');
- getline(MyReadFile, Tabulka[c].Hour, ';');
- cout << Tabulka[c].Name << Tabulka[c].Income << Tabulka[c].Hour << endl;
- c++;
- }
- }
- for (int i = 0; i < c; i++){
- Array[i] = Transfer_Hour(Tabulka[i].Hour, x);
- Finally[i].Time_In_Work = Transfer_Hour(Tabulka[i].Hour, y);
- Finally[i].Wage = Wage((Tabulka[i].Income), Array[i], x);
- Finally[i].Tax = Wage((Tabulka[i].Income), Array[i], y);
- Finally[i].Name = Tabulka[i].Name;
- Finally[i].Hour = Array[i];
- }
- CreateHTML(Finally, CountEmployee);
- cout << "Html uspesne vztvoreno" << endl;
- //co jsem zkousela, tak to nepada na vytvoreni html, on se ten soubor vytvori. Ono to pada na tom delete[]
- //moc nevim, proc to tady mazes, a uprimne mi tyhle alokace a mazani pameti vubec nesly, tak ti nevysvetlim proc,
- //bo nemam tuseni :D
- // delete[] Array;
- MyReadFile.close();
- cout << "Soubor uzavren." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement