Import .csv file into phpMyAdmin

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
easinewe
Forum Newbie
Posts: 23
Joined: Mon Jan 11, 2010 3:22 pm

Import .csv file into phpMyAdmin

Post by easinewe »

I have a csv file exported from Filemaker Pro that I am trying to import into phpMyAdmin but I keep getting the following error...

"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"115 Avenue A","Art & Paper","Shopping","4/14/2010 11:34:35 AM","","200001","40.' at line 1"

This is the first line of my csv file....

"115 Avenue A","Art & Paper","Shopping","4/14/2010 11:34:35 AM","","200001","40.726314","East Village, Manhattan","-73.983544","Alphabets","212-475-7250","","6 to Astor Place","Non-Major Attraction","ShopsmartShopping Unfolds","","10009"

Any idea why I am getting this error? Is my data not structured correctly? Seems like importing data of this type should be relatively simple.

Any help would be appreciated.
adityamenon90
Forum Newbie
Posts: 7
Joined: Fri Apr 16, 2010 1:41 pm

Re: Import .csv file into phpMyAdmin

Post by adityamenon90 »

Hi, there's a "dot" after the "40" numeral in the first line.

That dot is causing the problem. I am not really sure about the details, but I think you have some kind of problem with the data type for that field, maybe it isn't expecting any decimal places. Also, please try placing the escape operator "/" in front of the ".", and see if that solves the problem. If it does, then all you have to do is open up Notepad++, and do a find and replace search for all dots and replace them with "/."
easinewe
Forum Newbie
Posts: 23
Joined: Mon Jan 11, 2010 3:22 pm

Re: Import .csv file into phpMyAdmin

Post by easinewe »

Hmmm...

Tried to replace "." with "/." but I still go the same error. Any other ideas?
easinewe
Forum Newbie
Posts: 23
Joined: Mon Jan 11, 2010 3:22 pm

Re: Import .csv file into phpMyAdmin

Post by easinewe »

Anyone?
st3fanos
Forum Newbie
Posts: 12
Joined: Tue Apr 13, 2010 1:30 am

Re: Import .csv file into phpMyAdmin

Post by st3fanos »

Hi,

Not sure just a wild guess but there is a hidden character between Shopsmart and Shopping. I found this when I pasted it into textpad.

To be accurate the it's the '\v' (second line from the bottom in HEX 0B) and from that I can deduce with the help of google that it is known as a 'Vertical Tab' http://www.dynamoo.com/technical/ascii.htm

I am sure that this is not what you want to be inserting into your DB.

This is your statment as seen..

Code: Select all

0000000   "   1   1   5       A   v   e   n   u   e       A   "   ,   "
0000020   A   r   t       &       P   a   p   e   r   "   ,   "   S   h
0000040   o   p   p   i   n   g   "   ,   "   4   /   1   4   /   2   0
0000060   1   0       1   1   :   3   4   :   3   5       A   M   "   ,
0000100   "   "   ,   "   2   0   0   0   0   1   "   ,   "   4   0   .
0000120   7   2   6   3   1   4   "   ,   "   E   a   s   t       V   i
0000140   l   l   a   g   e   ,       M   a   n   h   a   t   t   a   n
0000160   "   ,   "   -   7   3   .   9   8   3   5   4   4   "   ,   "
0000200   A   l   p   h   a   b   e   t   s   "   ,   "   2   1   2   -
0000220   4   7   5   -   7   2   5   0   "   ,   "   "   ,   "   6
0000240   t   o       A   s   t   o   r       P   l   a   c   e   "   ,
0000260   "   N   o   n   -   M   a   j   o   r       A   t   t   r   a
0000300   c   t   i   o   n   "   ,   "   S   h   o   p   s   m   a   r
0000320   t  \v   S   h   o   p   p   i   n   g       U   n   f   o   l
0000340   d   s   "   ,   "   "   ,   "   1   0   0   0   9   "
0000356
I am therefor guessing you may need to write some form of filter to clean your data of hidden strange and worderfull characters.

But then again i'm just learning.. :) hope it helps
Regards
Stephen
rd.dcse
Forum Newbie
Posts: 7
Joined: Fri Jun 11, 2010 2:56 pm

Re: Import .csv file into phpMyAdmin

Post by rd.dcse »

Please send me the code for importing file content to mysql database rd.dcse@gmail.com

Thanks in advance
Post Reply