Jump to content

Importing CSV files - Quatations marks appear as a ? mark


Recommended Posts

Hello all- I thank you greatly in advance for any help...

 

I have a CSV file I am importing into my MySQL database and have a problem:

 

One of the cells I am importing uses quotations marks in the description (they need to be there!), but unfortunately, when I import it changes the quatations mark to a ? mark sign.

 

I changed "Fields terminated by" to a "+" and changed "fields enclosed by" to a ","... but this did nothing for me.

 

Again, I'd appreciate any help.

 

Thanks!

Those aren't regular quotes you're dealing with...they are 'Magic Quotes'!

 

And a magical pain in the ass.  Try replacing them as follows:

 

$string = preg_replace('/[\x91\x92]/u', "'", $string);

$string = preg_replace('/[\x93\x94]/u', '"', $string);

 

Oh wow, so right now the cell reads:

 

W90” x D39” x H31”

 

In the CSV file what would I change that to read???

 

Is this what you are saying?

 

W90string = preg_replace('/[\x91\x92]/u', "'", $string);

$string = preg_replace('/[\x93\x94]/u', '"', $string); x D39string = preg_replace('/[\x91\x92]/u', "'", $string);

$string = preg_replace('/[\x93\x94]/u', '"', $string); x H31string = preg_replace('/[\x91\x92]/u', "'", $string);

$string = preg_replace('/[\x93\x94]/u', '"', $string);

 

 

sorry i should've explained that better. 

 

I was giving advice on how to replace magic quotes with normal quotes in a php script, which you could do prior to an INSERT query. I'm not sure how you would issue this command in a text editor.  If nobody else answers here, just look up 'find and replace magic quotes'  on google.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.