i need to convert the above so i can insert it directly in to an sql database it need to look like this exactly not sure what is the best way to do it either somekind of script to convert the file or a sql script new to all this but getting there at the moment i have to do it manually which just takes me hours thanks in advance for your help
Forgot to add i would be willing to pay someone to do it
Lee
Don't bother; what you are asking is trivial. But we'll need some more information. What exactly is the format of the source file? What do each of those columns represent and how do they map to the resulting table? And we'll need to know what tools you have available. Perl? PHP? Or are you using a Windows box?
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
Your specification example has some inconsistencies like how the data items in the input text file are to map onto the mysql table.
Below is some python code that does mostly what you want. I wrote it on the fly and it isn't tested and as is the way with code may need a little work Anyway it gives you a framework that you should be able to bang into what you want done.
I would have included the correct command construction and tested it if the example had been more clear. In Python indenting is important. The indent on this wiki isn't clear so you may need to check the indents
import MySQLdb
msqluser="whatever the msysql user is"
password="The user password...not secure but tough"
infileName="paramraw.txt"
try:paramsfd=open(infileName=,"r")
except:print "Input filei " +infileName+ " not found"
#Connect to the mysql database
db = MySQLdb.connect("localhost",mysqluser,passwd = password)
cur=db.cursor()
#Read each line of the data input file and split on the colon delimeters
for tableRec in paramfd.readlines():fields=tableRec.split(":")
values="("for item in fields:values=values+","+item
sqlcmd="insert into `de_Coordonnee` (`ID`, `TYPE`, `POSIN`, `POSOUT`, `COORDET`, `COORDETOUT`, `NOTE`, `UTILISATEUR`, `udate`) values"sqlcmd+=values+");"
Sorry the indent didn't come out Uhhh
Okay all lines after the first for command are indented once except
the line following the second for command is indented twice
Bookmarks