Thursday, March 8, 2012

Transform comma text file in SQL insert file

From unix prompt:

perl -pi.bak -e "s/,/','/g;s/^/insert into tab\(x,y\) values \('/g;s/$/'\);/" filename.dat

where:
more filename.dat

11111111,1
.........

After change, there will be one backup file of the original file.

No comments:

Post a Comment