this seems to me to be exactly the same issue as reported in #1350162: CSV unrecognized
i have Node Export and Node Export CSV installed. i export a node in CSV format and then try to paste that code into the Import form. i also try downloading the export to a file and then importing that file.
in both cases, i get "Node export was unable to recognize the format of the supplied code. No nodes imported."
the problem is that when node_export_csv_node_export_import() compares the counts of the first and second rows of the array created by node_export_csv_csv_to_array(), the counts are unequal. some further testing showed that the data row is missing some keys:
2 : language
18 : log
22 : picture
26 : menu['link_title']
it is apparently not handling blank cells correctly - the parts of the original CSV line that look like ",123,,456,"
if i take the CSV and use it to define arrays in a PHP file, delimiting all of the cells with double quotes, the counts are equal.
this is the sample export CSV
nid,type,language,uid,status,created,changed,comment,promote,moderate,sticky,tnid,translate,vid,revision_uid,title,body,teaser,log,revision_timestamp,format,name,picture,data,uuid,revision_uuid,menu['link_title'],menu['mlid'],menu['plid'],menu['menu_name'],menu['weight'],menu['module'],menu['expanded'],menu['hidden'],menu['has_children'],menu['customized'],menu['parent_depth_limit']
465,story,,1,1,1330139899,1330139903,0,1,0,0,0,0,735,1,test story node for export / import,this is only a test,this is only a test,,1330139903,1,admin,,a:0:{},5ff26ce0-5f5f-11e1-a208-0019d169b656,FALSE,,0,0,primary-links,0,menu,0,0,0,0,8
even if i change that CSV to look like 465,story,"",1,1,... the import fails. it looks like node_export_csv_csv_to_array() is depending on there being some value between enclosures to create a cell in the row of the array it creates.
Comments
Comment #1
danielb commentedThanks for reposting and narrowing down the problem and investigating column counts (that was the problem in the other issue). I've got a lot of pies to cook, but I'll be sure to test out this case soon.
Comment #2
danielb commentedI can confirm the bug plus additional problems with some code that hasn't been backported from D7
Comment #3
danielb commentedI've committed some fixes and they'll appear in the next dev snapshot (check the date is after this posting). It should add "" instead of empty strings, so you'll have to export again. It also fixes stuff on the import side of things and changes how variables are decoded.
Comment #4
danielb commentedHmm it seems to output
""""""instead of""Not really ideal, obviously "" gets enclosed in more "" and then each " gets escaped with another ", but it works.
I'll see if I can improve it though.
Comment #5
danielb commentedOK I'm pretty happy with it, have made another commit. I'll leave the issue open a little while in case there are any objections.
Comment #6
danielb commentedHmm it really should handle the original case you reported, but it seems pretty hard to do because of how it works :/
I'll fiddle about with it and see.
Comment #7
danielb commentedAlright I've changed it again, removed the "" strategy, now it should detect double commas ,, and assume an empty value exists there.
So with this new code you should be able to import your old CSV that you already exported.
Comment #8
brad.bulger commentedI downloaded the latest dev version and tried the same case again - worked like a charm. I tried pasting the CSV produced by export into the import form, worked fine. I also confirmed that downloading the CSV as a file and then importing from the file worked.
Thanks for digging into this!
Comment #9
brad.bulger commentedoh, i see, this is still the multiple double-quotes. i'll try it again in a while to pick up the latest changes.
Comment #10
brad.bulger commentedUsing the 27 Feb dev build, the only issue I'm seeing now is a different one - I'm getting eval parse errors trying to import a node with single quotes in the text.
The import CSV:
The parse errors, and the code that caused them:
When I put in a quick hack to escape the single quotes, everything else looked fine - the null values are unquoted, the CSV imports fine as pasted code and uploaded file, and the downloaded CSV file opens correctly as a spreadsheet.
Comment #11
danielb commentedI've just committed a quick hack for that too then.
Comment #12
danielb commented