passing data from text file in to mysql database?
Posted on 2002-07-24
I wanted to pass data from from txt file in to mysql db.
the data is testing results of few boards(tested) in which I have serial number of the board,few testing parameters,& result=Fail or Pass.
my requirement is as follows:-
1)I need to read each line of the data in txt file
2)then have to check whether that particular board already exists in the database
if it already exists check for fail or pass status in db.
then the current line of data should overwrite the existing data in db.
then the current line of data should be added in to db.
3)this loop should be done until end of the txt file.
can I do this way of overwriting & adding data from text file line by line.
if possible can anyone suggest me the way to resolve it.
The problem now I feel I would face is, all the while I pass the whole data in to db by following query
"load data infile '".$path."".$category.".tmp' into table ".$category." fields terminated by\",\";"
but if I wanted to add data & overwrite data(if any) line by line in to db how to go about it.
if any one could suggest me!!!!!!! pls kindly do that.