Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Below is the exact solution (assuming that your php and mysql resides on the same server)</p> <p>suppose your csv file is</p> <pre><code>"1";"Desserts";"1";"category/vcm_s_kf_repr_806x645_7.jpg" "2";"Beverages";"1";"category/aagya.jpg" "3";"apetizers";"1";"category/Koala.jpg" "13";"Breakfasts";"1";"category/Lighthouse_2.jpg" "5";"Vegeterian entries";"1";"category/Desert.jpg" "6";"Naan and Breads";"1";"category/Lighthouse_1.jpg" "7";"Mexican";"1";"category/vcm_s_kf_repr_832x624_2.jpg" </code></pre> <p>say you have files like 001.csv, 002.csv and so on make one table exactly with same field that are in csv files</p> <pre><code>CREATE TABLE `sample` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 100 ) NOT NULL , `flag` INT NOT NULL , `path` VARCHAR( 100 ) NOT NULL , PRIMARY KEY ( `id` ) , UNIQUE ( `id` ) </code></pre> <p>Then run a code below according to your customization </p> <pre><code>mysql_connect("localhost","root",""); mysql_select_db("csv"); //find the current working f=directory $dir=getcwd(); foreach (glob("*.csv") as $key=&gt;$val) { echo $sql="LOAD DATA INFILE '".$dir."//".$val."' INTO TABLE sample"; //now fire your update query , as an example here i am trying to replace all jpg with gif mysql_query($sql) or die(mysql_error()); echo $update="UPDATE sample SET path=REPLACE( path, '.jpg', ',bmp' )"; mysql_query($update); //delete the table for next csv echo $outfile="SELECT * INTO OUTFILE '" .$dir."/converted_".$val."' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' FROM sample"; mysql_query($outfile); $del="delete from smaple"; mysql_query($del); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload