Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BILL OF MATERIALS
01-20-2016, 07:13 PM,
#2
RE: BILL OF MATERIALS
I don't think there is a script to do it, but mysql does have it's own command for importing csv files. So assuming you have a csv file with the data like this:

+-----------------+-------------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+------------+-------+
| parent | varchar(20) | NO | | | |
| sequence | int(11) | YES | | 0 | |
| component | varchar(20) | YES | | | |
| workcentreadded | char(5) | YES | | | |
| loccode | char(5) | YES | | | |
| effectiveafter | date | YES | | 0000-00-00 | |
| effectiveto | date | YES | | 0000-00-00 | |
| quantity | double | YES | | NULL | |
| autoissue | tinyint(4) | YES | | 0 | |
+-----------------+-------------+------+-----+------------+-------+

All you need is to issue the following command to mysql:

LOAD DATA INFILE "/path/to/your/file/boms.csv"
INTO TABLE bom
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;

You will need to adjust the line terminator if your file has windows line terminators instead of unix and the last part says to ignore the first line of the file assuming they are headers. Obviously change for your file.

Thanks
Tim
Reply


Messages In This Thread
BILL OF MATERIALS - by petero@laballieds - 01-20-2016, 05:38 PM
RE: BILL OF MATERIALS - by TimSchofield - 01-20-2016, 07:13 PM
RE: BILL OF MATERIALS - by petero@laballieds - 01-20-2016, 08:23 PM
RE: BILL OF MATERIALS - by TimSchofield - 01-20-2016, 10:50 PM
RE: BILL OF MATERIALS - by petero@laballieds - 01-20-2016, 11:51 PM
RE: BILL OF MATERIALS - by agaluski - 01-21-2016, 12:43 AM
RE: BILL OF MATERIALS - by petero@laballieds - 01-21-2016, 09:16 PM
RE: BILL OF MATERIALS - by TimSchofield - 01-21-2016, 09:46 PM
RE: BILL OF MATERIALS - by petero@laballieds - 01-22-2016, 11:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)