Marqual Brown - 2017-11-27

Need Help. The program compiles and runs but not working to full capacity. I cant figure out how to make the program pick up spaces. I have "trash bag" and "trash can" in my code but it only picks up trash, and its to many frequencies for the item .

#include <iostream>
#include <map>
#include <iterator>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>

using namespace std;
string isLower(string s)
{
    string data = s;
    std::transform(data.begin(), data.end(), data.begin(),::tolower);
    return data;

 }

string trim(string str)
{
    stringstream trimmer;
    trimmer << str;
    str.clear();
    trimmer >>str;
    return str;
}

int main()
{

    map<string, int> item_count;
    string line;    // variable used to read a line from file
    int lines =0;   // variable containing the numbers of transactions
    ifstream myfile("C:/Users/marqu_000/Documents/marketda.txt");

    if(myfile.is_open())  // checking if the file was open
    {
        getline(myfile, line); // to ignore the first line which contains number of transactions 
        while(getline(myfile, line)) // read the file line by linr until end of file is reached
        {
            //now we are processing each line
            stringstream ss(line);
            int i;
            string item;
            // ignore Transection ID, #of Items
            getline(ss, item, ',');
            getline(ss, item, ',');
            while (getline(ss, item, ','))
            {
                item = trim(isLower(item));
                // Now the item variable is containing the item name
                map <string, int> :: iterator itr = item_count.find(item);
                if (itr == item_count.end())
                {
                    //means the element is not present
                    item_count.insert(pair<string, int>(item, 1));

                }
                else
                {
                    // increment the count
                    itr->second = 1 + itr -> second;
                }
            }
        }
        // now traverse in the array and print entries which have count 1 
        cout << "unique item: " << endl;
        for( map<string, int>::const_iterator it = item_count.begin(); it != item_count.end(); ++it)
        {
            cout << it -> first << endl;
        }
    cout << endl << "Items frequencies: " << endl;
    for( map<string, int>::const_iterator it = item_count.begin(); it != item_count.end(); ++it)
    {
        cout << it->first << ":" << it->second << endl;
    }
    myfile.close(); //closing the file
    }
    else 
    {
        cout << "Unable to open input file." << endl;
        return 1;
    }
    return 0;
}