Created
September 17, 2015 00:44
-
-
Save akehoyayoi/e0bc942e72001e816027 to your computer and use it in GitHub Desktop.
convert data from SQLServer to MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convertLine(line) | |
line = line.gsub("]","").gsub("[","") | |
line = line.gsub(" +09:00","") | |
# 変換候補文字列を抽出 | |
# ex. N'POINT (0 0)' -> GeomFromText('POINT (0 0)') | |
points = line.scan(/N'POINT \(.+?\)'/) | |
points.each do |point| | |
line = line.gsub(point,point.gsub("N'","GeomFromText('").gsub(")'",")')")) | |
end | |
line + ";" | |
end | |
def convertSQL(path) | |
File.open(path, 'r:utf-8') do |f| | |
f.each_line do |line| | |
puts convertLine(line) | |
end | |
end | |
end | |
convertSQL(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment