Frozenfire92 / Sobeys-IBM-Hackathon

1 stars 0 forks source link

Load from CSV into Database with renamed columns #9

Open Glavin001 opened 9 years ago

Glavin001 commented 9 years ago

See http://stackoverflow.com/a/13372912/2578205

Glavin001 commented 9 years ago

I used http://www.sequelpro.com/ instead.

Glavin001 commented 9 years ago

Having some trouble with the CALENDAR_DT field in sale table.

Glavin001 commented 9 years ago

Using Sequel Pro is working great. We will not be writing a SQL script to load.

Here was my work-in-progress script:

LOAD DATA LOCAL INFILE '~/Downloads/SobeysData/SALES_Header.csv' 
INTO TABLE `sale` 
LINES TERMINATED BY '\n'
(transactionRk, @calendarDt, `time`, itemSk, retailOutletLocationSk, @posTerminalNo, @cashierNo, itemQuantity, itemWeight, salesUOMCode, sellingRetailAmount, promoSalesCode, @stapleItemFlag, regionCode, customerSk)
SET `date` = STR_TO_DATE(@calendarDt, '%d%b%Y');