Maruf_Hasan

find in csv

Jun 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. void read_record()
  7. {
  8. fstream fin;
  9. fin.open("new1.csv",ios::in);
  10. {
  11. cout<<"E"<<endl;
  12. string name;
  13. cin>>name;
  14. vector<string>row;
  15. string line,word,temp;
  16. int cnt=0;
  17. while(!fin.eof())
  18. {
  19.  
  20. row.clear();
  21. getline(fin, line);
  22. stringstream s(line);
  23. while(getline(s, word, ','))
  24. {
  25. //cout<<word<<endl;
  26. row.push_back(word);
  27. }
  28. if(name==row[0])
  29. cout<<row[1]<<endl;
  30. // for(int i=0;i<row.size();i++)
  31. // cout<<row[i]<<" ";
  32. // cout<<endl;
  33. }
  34. }
  35. fin.close();
  36.  
  37. }
  38. int main()
  39. {
  40. read_record();
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment