TRUNCATE ventas;
LOAD DATA INFILE 'C:\\files\\espacios.txt' INTO TABLE ventas FIELDS TERMINATED BY '|' ENCLOSED BY '@' ESCAPED BY '' LINES TERMINATED BY '\n'  IGNORE 1 LINES(
 @col1
 ) set   
 EMPVTA=SUBSTRING(@col1,1,63),
 DIAVTA=SUBSTRING(@col1,63,2),
 MESVTA=SUBSTRING(@col1,65,4),
 ANOVTA=SUBSTRING(@col1,69,6),
 NDIVTA=SUBSTRING(@col1,75,24),
 HORVTA=SUBSTRING(@col1,99,13),
 PZAVTA=SUBSTRING(@col1,99,13),
 UMPVTA=SUBSTRING(@col1,112,11),
 CUNVTA=SUBSTRING(@col1,123,16),
 CEMVTA=SUBSTRING(@col1,139,13), /* CANTIDAD DE EMPAQUE EN PIEZAS */
 UEMVTA=SUBSTRING(@col1,152,20),
 PRDVTA=SUBSTRING(@col1,172,40),
 MTUVTA=SUBSTRING(@col1,212,37), /* MONTO UNITARIO DE VENTA (P.UNITARIO)*/
 MTTVTA=SUBSTRING(@col1,249,17), /* MONTO TOTAL DE VENTA  (CEMVTA X MTUVTA) */ 
 COLVTA=SUBSTRING(@col1,266,17),
 MUNVTA=SUBSTRING(@col1,306,40), 
 CIUVTA=SUBSTRING(@col1,346,40),
 TIPVTA=SUBSTRING(@col1,386,40),
 CANVTA=SUBSTRING(@col1,426,40),
 ETDVTA=SUBSTRING(@col1,466,13), /* EXISTENCIA EN TIENDA */
 ETOVTA=SUBSTRING(@col1,479,13), /* EXISTENCIA TOTAL */
 PRVVTA=SUBSTRING(@col1,492,13),
 CVEVTA=SUBSTRING(@col1,532,10), 
 REFVTA=SUBSTRING(@col1,542,10),
 CVCVTA=SUBSTRING(@col1,552,10),
 NOCVTA=SUBSTRING(@col1,562,40),
 RFCVTA=SUBSTRING(@col1,602,40),
 PRMVTA=SUBSTRING(@col1,642,35),
 NLTVTA=SUBSTRING(@col1,677,13), /* NÚMERO DE CAJAS 9LT - CUERVO */ 
 FECHA=date_format(str_to_date(SUBSTRING(@col1,1240,10), '%m/%d/%Y'), '%Y-%m-%d'), 
 STATUS=SUBSTRING(@col1,1250,1),
 SERIE=SUBSTRING(@col1,1251,3), 
 FOLIO=SUBSTRING(@col1,1254,8), 
 DOCUME=SUBSTRING(@col1,1262,25), 
 UUID=SUBSTRING(@col1,1287,40),
 SUCURS=SUBSTRING(@col1,1327,40), 
 COSTO=SUBSTRING(@col1,1367,17),
 UTILID=SUBSTRING(@col1,1384,17), 
 created_at=NOW(); 

