I am working on porting over a database from a custom MSSQL CMS to MYSQL - Wordpress. I am using Python to read a txt file with \t
delineated columns and one row per line.
I am trying to write a Python script that will read this file (fread) and [eventually] create a MYSSQL ready .sql file with insert statements.
A line in the file I'm reading looks something like:
1 John Smith Developer http://twiiter.com/johns Chicago, IL
My Python script so far:
import sys
fwrite = open('d:/icm_db/wp_sql/wp.users.sql','w')
fread = open('d:/icm_db/users.txt','r')
for line in fread:
print line;
fread.close()
fwrite.close()
How can I "implode" each line so I can access each column and do business on it?
I need to generate multiple MYSQL insert statements per line I read. So... for each line read, I'd generate something like:
INSERT INTO `wp_users` (`ID`, `user_login`, `user_name`)
VALUES (line[0], 'line[2]', 'line[3]');