Export it to comma delimited file and parse it with a shell script (Watch for line wrap):
#!/bin/sh
##############################################################################################
Use this file to parse Inventory.txt, a comma
delimmited file which includes the following fields:
ITEM_NUMBER,MFR_PART,DESCRIPTION,PRICE_2,PRICE_1
the output should be redirected into a file.sql, ie:
./createSQLfile > outfile
#
Now you are ready to import the data into MySQL with:
mysql -uUSERNAME -pPASSWORD < database.sql (replace USERNAME and PASSWORD with yours)
note: you may get some syntax errors about apostrophies, if so
you'll need open database.sql and remove the apostrophie to continue
##############################################################################################
echo "
drop database skudb;
create database skudb;
use skudb;
DROP TABLE IF EXISTS skus;
CREATE TABLE skus (
id VARCHAR(100),
mfrpart VARCHAR(100),
description VARCHAR(200),
price2 VARCHAR(15),
price1 VARCHAR(15),
record_number VARCHAR(20)
PRIMARY KEY (id),
);
"
FILE=inventory
line=2 # start at line 2, since line 1 is the field names
linecount=wc -l $FILE |cut -d ' ' -f4
until [ "$line" = "$linecount" ]
do
gline=sed -n "$line{p;q;}" $FILE
itemnum=echo $gline |cut -d ',' -f1
id=$itemnum
mfrpart=echo $gline |cut -d ',' -f2
description=echo $gline |cut -d ',' -f3| sed s/"'"//
price2=echo $gline |cut -d ',' -f4
price1=echo $gline |cut -d ',' -f5
#echo "INSERT INTO skus VALUES (${id},'${mfrpart}','${description}','${price2}','${price1}');"
echo "INSERT INTO skus VALUES ( '$id', '$mfrpart', '$description', '$price2', '$price1', '$id')
;"
line=expr $line + 1
done