I am doing some data file imports using:
LOAD DATA
INFILE 'apa.txt'
INTO TABLE Test_Stock_Daily
FIELDS TERMINATED BY ','
(symbol, date, open, high, low, close, volume);
The date in the file is formatted mm/dd/yyyy. I need it to be yyyymmdd in the database.
The volume field needs to be truncated by two places so 123456 becomes 1234.
What are the most SQL-centric ways of doing this?
Best Answer
Here is what I settled on:
Some sample data:
Some sample output:
It would be really nice if I could replace all those 'APA's with a variable, but I gather that I can't do that without using a stored procedure so I think that I'll wrap in up in a Python wrapper like so:
Thanks to all!