in reply to split a line into 2 variables and store in SQL
With PostgreSQL, you'd use a one-liner:
input file:
$ cat sharan.txt apple <= banana; cat := dog; elephant <= flag;
import:
$ perl -ne ' chomp; chop; my@arr=split(); print $arr[0], "\t", $arr[2], "\n";' sharan.txt \ | psql -d test -c " /* drop table if exists sharan_txt; */ create table sharan_txt(col1 text, col2 text); copy sharan_txt from stdin csv delimiter E'\t'; "
check:
$ psql -d test -c "select * from sharan_txt" col1 | col2 ----------+-------- apple | banana cat | dog elephant | flag (3 rows)
hth
|
|---|