CSV to MySql Database Problem.

Discussion in 'PHP' started by kasun0777, Jun 10, 2011.

  1. #1
    i have some csv file. like this
    #XXX;XXX;XXX;XXX;,
    "xxx;""xxx"";XXX;yyy",
    "xxx;""xxx"";XXX;yyy",
    "xxx;""xxx"";XXX;yyy",
    "xxx;""xxx"";XXX;yyy",
    Code (markup):
    i want import to MySQL.
    with remove 1st row (# line)
    and remove " marks.

    this is my coding.
    
    $query = "load data local infile '/sample.csv' into table mytable fields terminated by ';' lines terminated by '\n' (aa, bb, cc, dd)# Affected rows: 1";
    
    Code (markup):
    data was insert to mysql database. but ddnt remove 1st row. and ddnt remove "" marks.

    Help me in Advance
    Thanks
     
    kasun0777, Jun 10, 2011 IP
  2. TheMarketeer

    TheMarketeer Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you might try using something like PHPmyadmin and letting it take care of importing the CSV for you. It can parse the marks by default.
     
    TheMarketeer, Jun 10, 2011 IP
  3. kasun0777

    kasun0777 Well-Known Member

    Messages:
    355
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #3
    yes i import that.
    i put Fields enclosed by "
    but "xxx;""xxx"";XXX;yyy", this is the problem.
     
    kasun0777, Jun 10, 2011 IP