C++ Unzip and parse csv using zip.h

42 Views Asked by At

I have a file myfile.zip that contains a csv that I am trying to parse. I have created a structure like the following:

struct Customer {
    int id;
    double quantity;
    long timestamp;
};

i have linked

#include <zip.h>

But I do not manage to unzip and directly read the csv to get the data in a vector.

I did this:

vector<Customer> read_data(const string& filename) {
    vector<Customer> customers;
    ifstream file(filename);
    string line;
    getline(file, line);
    while (getline(file, line)) {
        Customer customer;
        stringstream ss(line);
        ss >> customer.id >> customer.quantity >> customer.quantity >> customer.timestamp;
        customers.push_back(customer);
    }
    file.close();
    return customers;
}

But it does not manage to unzip I believe and so it gives 000 Any idea how I could please?

0

There are 0 best solutions below