miguelmarve

getion_de_csv

Oct 29th, 2021
1,384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. // gestion_archivos.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include<string>
  7. #include <fstream>
  8. #include<sstream>
  9. #include<vector>
  10. using namespace std;
  11. char Nombre[15], Fecha[15];
  12. vector<string> row;
  13.  int rollnum, roll2, count = 0;
  14. string myText, line, word;
  15. int columnaUno[10000], columnaDos[10000];
  16. int main() {
  17.     // Create and open a text file
  18.     int i=0;
  19.     ifstream MyFile("prueba7A2.txt");
  20.   while(getline (MyFile, myText))
  21.     {
  22.          row.clear();
  23.         stringstream s(myText);
  24.         while (getline(s, word, ','))
  25.         {
  26.             row.push_back(word);
  27.         }
  28.         //roll2 = stoi(row[0]);
  29.         cout<<"Dato en la ubicacion cero:"<<row[0]<<" dato en la ubicacion uno:"<<row[1]<<endl;
  30.         columnaUno[i]=stoi(row[0]);
  31.         columnaDos[i]=stoi(row[1]);
  32.         i++;
  33.         //system("pause");
  34.     }
  35.     // Close the file
  36.     MyFile.close();
  37.     system("Pause");
  38. }
Advertisement
Add Comment
Please, Sign In to add comment