-
-
Save parzibyte/629bb4f08f7ded6d7af32d27ee074a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://parzibyte.me/blog | |
*/ | |
#include <iostream> | |
#include <sstream> | |
#include <fstream> | |
#define NOMBRE_ARCHIVO "ProductosExportados_SPOS3.csv" | |
using namespace std; | |
int main() | |
{ | |
ifstream archivo(NOMBRE_ARCHIVO); | |
string linea; | |
char delimitador = ','; | |
// Leemos la primer línea para descartarla, pues es el encabezado | |
getline(archivo, linea); | |
// Leemos todas las líneas | |
while (getline(archivo, linea)) | |
{ | |
stringstream stream(linea); // Convertir la cadena a un stream | |
string idProducto, codigoBarras, descripcion, precioCompra, precioVenta, existencia, stock; | |
// Extraer todos los valores de esa fila | |
getline(stream, idProducto, delimitador); | |
getline(stream, codigoBarras, delimitador); | |
getline(stream, descripcion, delimitador); | |
getline(stream, precioCompra, delimitador); | |
getline(stream, precioVenta, delimitador); | |
getline(stream, existencia, delimitador); | |
getline(stream, stock, delimitador); | |
// Imprimir | |
cout << "==================" << endl; | |
cout << "Id: " << idProducto << endl; | |
cout << "Codigo de barras: " << codigoBarras << endl; | |
cout << "Descripcion: " << descripcion << endl; | |
cout << "Precio de compra: " << precioCompra << endl; | |
cout << "Precio de venta: " << precioVenta << endl; | |
cout << "Existencia: " << existencia << endl; | |
cout << "Stock: " << stock << endl; | |
} | |
archivo.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment