Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code field empty when trying to import CSV file #40

Open
kaiwa opened this issue Jan 8, 2016 · 6 comments
Open

Code field empty when trying to import CSV file #40

kaiwa opened this issue Jan 8, 2016 · 6 comments

Comments

@kaiwa
Copy link

kaiwa commented Jan 8, 2016

See https://wordpress.org/support/topic/import-from-csv-not-working

This problem is caused by the byte order mark (0xEFBBBF) preceeding the export downloaded from dfp. The csv reader puts the BOM into the first array key and so $row['#Code'] fails because it is actually $row[chr(0xEF).chr(0xBB).chr(0xBF).'#Code']

Temporary solution is opening the export in vim and removing the BOM with :set nobomb.

@tdmalone
Copy link

tdmalone commented May 6, 2016

I had this problem as well; here's what I submitted to https://www.chriswgerber.com/dfp-ads/import-from-csv/ (which is awaiting moderation):

For some reason, DFP is adding a & #65279; character to the start of the file (I think DFP is doing it?) which then causes the importer to fail, because #Code is actually called & #65279;#Code. I fixed it by copying and pasting the CSV to a new file in Notepad.

@hdraye
Copy link

hdraye commented Jun 18, 2016

Hi tdmalone
I tried the copy/paste method, does not work, can you please elaborate.
I downloaded vim editor, did not know how to deal with it

@tdmalone
Copy link

tdmalone commented Jun 20, 2016

Hi @hdraye, it may or may not be the exact same problem you're experiencing, but basically I found the character (which is a 'zero width no-break space', see here for details) couldn't be removed easily by trying to edit it out.

Copying and pasting the entire text of the CSV into Notepad, and then saving as a brand new CSV file, removed the character. I don't totally understand character-encoding but it could be because Notepad didn't support that particular character, so stripped it out. There are probably better ways to solve this but this is what I did.

@chriswgerber
Copy link
Owner

Thanks for reporting this. If someone would like to submit a PR and filter out the BOM I would be able to test and merge. I don't have the bandwidth to make the change myself.

Here's an example of how it can be removed: http://stackoverflow.com/a/15423899/2697450

@krossekrabbe
Copy link

@ThatGerber, I remember vaguely that when I checked I thought this probably should be fixed in the CSV lib you are using to handle files. Maybe you can have a look when you have some time and if it's a bug in the library we can report it over there.

@chriswgerber
Copy link
Owner

@krossekrabbe Would be able to provide an example file that I could use to test a potential fix? Like I said in another post, I don't work in PHP or DFP much anymore and don't have access to a file to recreate it. My email address is in my profile. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants