Tagged: csv, csv upload, Form Builder
- This topic has 13 replies, 2 voices, and was last updated 9 years, 5 months ago by BePro Software Team.
-
AuthorPosts
-
October 12, 2015 at 1:12 pm #7094CosminMember
Salut,
I have some understanding issues on how to “persuade” the csv-upload to work with FormBuilder custom fields.Lets say we have Form ID 2 named FormNo2.
Lets say we have defined the following fields: item_name, gr_abc, con_xyz, a_textarea[],gr_asdfThen a proper csv file would look like this:
item_name;form_id;gr_abc;con_xyz;a_textarea[];gr_asdf
Item Name;2;ABC;;option_1,option_2;ASDFAm I missing something?
The upload creates the “empty” List entry but no Form fields entries [no entry into the bepro_listing_form table].Is there a trick I am missing? The csv documentation does not cover the FormBuilder.
Thanks for your time!
October 12, 2015 at 9:48 pm #7098BePro Software TeamKeymasterHi,
Your best bet is to use the BePro Listings Exports plugin. It gets the fields and exports a properly formatted csv
– https://www.beprosoftware.com/shop/bepro-listings-export
You can setup the csv file yourself by tying the following:
– “a_textarea” should not have brackets after it in the csv.
– To specify form 2, you should use the heading “bl_form_id”.Let us know if these steps help.
___
BePro Software TeamOctober 13, 2015 at 10:08 am #7100CosminMemberSalut,
thanks for your heads up – the bl_form_id was needed for the upload on the form table.I have a problem with checkbox and categories fields
The csv-upload ignores coma separated categories and messes up the checkboxes values by quoting the whole thing in double quotes, for example none of these work for checkbox:a,b,c "a,b,c" "a","b","c" [a,b,c] ["a","b","c"] a|b|c
So how do I write checkbox values?
October 13, 2015 at 11:13 am #7102BePro Software TeamKeymasterHi,
What delimiter are you using?
___
BePro Software TeamOctober 14, 2015 at 6:28 pm #7128CosminMemberSalut.
Delimiter is ;
bl_form_id;checkboxfield;dropdown 2;a,b,c;x
October 14, 2015 at 8:01 pm #7130BePro Software TeamKeymasterHi,
It looks like you should be using the following
2;”a,b,c”;x
If you have actual category ID’s, that would be best
___
BePro Software TeamOctober 15, 2015 at 8:05 pm #7162CosminMemberIt is simply not working.
“a,b,c” is added in database as “a,b,c” when the expected format is [“a”,”b”,”c”]
Trying to add [“a”,”b”,”c”] ends-up as “[\”a\”,\”b\”,\”c\”]”I’m running Listings 2.1.99991 and Form Builder 1.0.36
I see that Listings 2.1.99999 (July 23rd, 2015) made some changes for csv-upload but none refer to check box fields.October 15, 2015 at 8:42 pm #7169BePro Software TeamKeymasterHi,
Thanks for sharing these details. Is there are reason why you have not updated both BePro Listings and the Form Builder to the latest version?
___
BePro Software TeamOctober 19, 2015 at 12:03 pm #7206CosminMemberYes,
various improvements and custom code made to some functions – I needed to finish developing before handling cosmetics.I haven’t got my time to deal with this issue ftm, do you think there’s an update I’m missing in order to make this functionality work in the expected way?
Thanks
October 19, 2015 at 12:15 pm #7211BePro Software TeamKeymasterYes,
I believe that if you upgrade, the category upload will be fixed. We released an upgrade directly addressing it, check out changelog. Once that is confirmed fixed, we can focus on diagnosing the checkbox upload issue
___
BePro Softare TeamNovember 23, 2015 at 3:08 pm #7524CosminMemberHello.
I have updated both listings and form builder to the latest release.Uploading by csv does not work for checkbox fields!
Example for 3 checkbox fields in the csv file:
checkbox fields: gr_program;gr_limbi_secundare;gr_curriculum;
delimiter: ;What’s in the CSV
bl_form_id;item_name;gr_program;gr_limbi_secundare;gr_curriculum;gr_alimentatie;gr_somn;gr_limba_principala
2;CSV Temp V4;"scurt,lung,mediu";[Engleză,Franceză];Curriculum Britanic,Curriculum Francez;"Bucătărie Proprie";da;Română
What’s in the DB
{"item_name":"CSV Temp V4","gr_program":"scurt,lung,mediu","gr_limbi_secundare":"[Englez\u0103,Francez\u0103]","gr_curriculum":"Curriculum Britanic,Curriculum Francez","gr_alimentatie":"Buc\u0103t\u0103rie Proprie","gr_somn":"da","gr_limba_principala":"Rom\u00e2n\u0103","save_bepro_listing":1}
As you can see, none of the 3 variants work for a checkbox field – the DB output should have been:
“gr_program”:[“scurt”,”lung”,”mediu”]Please give me a solution.
November 25, 2015 at 1:11 am #7528CosminMemberSalut.
Can you tell me the name of the function dealing with csv uploads?November 25, 2015 at 5:14 am #7529CosminMemberI performed the following fix:
In bepro_listings_admin.php
I changed this loop to verify that csv field looks like [option,option,option…]
Basically all the check-box fields should be in square brackets.while (($results = fgetcsv($file,0,$delimiter)) !== false){ if($counter > 0){ $_POST = ""; foreach($results as $key => $result){ // START OF joe csv upload if ( preg_match("~^\[(.)*\]$~",$result) ){ $result=substr(substr($result,0,-1),1); $checkbos_result=explode(",",$result); $_POST[$csv_titles[$key]] = $checkbos_result; //var_dump($result); } else{ $_POST[$csv_titles[$key]] = $result; } // END OF joe csv upload //$_POST[$csv_titles[$key]] = $result; }
also note that fgetcsv from this loop was restricted to 1500 characters – this should be customised in admin dashbord as it creates an artificial limit of 1500 characters to the file [and 0=unlimited by default is not desirable as it should be slower]
November 25, 2015 at 9:31 am #7531BePro Software TeamKeymasterHi,
Thanks for sharing this code snippet. Our development team will test your solution and confirm its the best approach.
___
BePro Software Team -
AuthorPosts
- You must be logged in to reply to this topic.