This banks on the assumption of a Tab ''
as the column delimiter.
Modify your Hash as you will. I just put the sha2()
in as a placeholder for now.
It took a while to figure this out. I had to go into 'Edit' of your question to assume there were tabs. And finally found a peer Answer over Here by user peixe.
You never supplied a schema, so I flew with this one. Add your Time column if you want. But I collapsed the date and time into one column with now()
into a datetime
.
Schema:
drop table if exists pumpkin001;
create table pumpkin001
( Tag int auto_increment primary key,
ID varchar(10) not null,
Name varchar(100) not null,
Email varchar(100) not null,
Type varchar(100) not null,
Hash varchar(1000) not null,
Date_Update datetime not null
);
Load (Windows):
LOAD DATA LOCAL INFILE 'c:\nate\file007.txt'
into table pumpkin001
COLUMNS TERMINATED BY ''
LINES TERMINATED BY '
'
IGNORE 1 LINES
(@ID, @Name, @Email, @Type)
SET ID=@ID, Name=@Name, Email=@Email, Type=@Type,
Hash=sha2(@ID,384), Date_Update=now();
Load (Linux):
LOAD DATA LOCAL INFILE 'file007.txt'
into table pumpkin001
COLUMNS TERMINATED BY ''
LINES TERMINATED BY '
'
IGNORE 1 LINES
(@ID, @Name, @Email, @Type)
SET ID=@ID, Name=@Name, Email=@Email, Type=@Type,
Hash=sha2(@ID,384), Date_Update=now();
Results:
select Tag,ID,Name,Email,Type,left(Hash,50) as L50_Hash,Date_Update from pumpkin001;
+-----+-------+------------+-----------+---------+----------------------------------------------------+---------------------+
| Tag | ID | Name | Email | Type | L50_Hash | Date_Update |
+-----+-------+------------+-----------+---------+----------------------------------------------------+---------------------+
| 1 | 12345 | Jackson, F | fj@me.com | Level 1 | 0fa76955abfa9dafd83facca8343a92aa09497f98101086611 | 2016-07-14 18:21:40 |
| 2 | 67890 | Stewart, J | js@me.com | Level 1 | 6988c291a83b05760b93263fc78e8feeca8ca4641b007c6978 | 2016-07-14 18:21:40 |
| 3 | 43210 | Fuller, T | tf@me.com | Level 2 | 6d07aa9758595e1dfe5dca93acc46dea01fef0856fe7dadf04 | 2016-07-14 18:21:40 |
| 4 | 62295 | Lewis, M | ml@me.com | Level 2 | f3d4154869ef03ff09ea778b5066bd909c3ce5baf894e0593b | 2016-07-14 18:21:40 |
+-----+-------+------------+-----------+---------+----------------------------------------------------+---------------------+