Forums

Import CSV content (multi-row) and view on data grid

abombazza 13 Apr, 2016
hi at all.
i need to import a csv files with 20 row and 6 columns about every month.
I have done the table with this columns but i don't understand how i can connect the columns on csv to the columns of table-db.

After that i need to view all records in a table-view or data grid view and by one filed i could select witch of this are still available or not.

Can someone help me plese ?
thank you
GreyHead 14 Apr, 2016
Hi abombazza,

For the titles, I would make them the same as the column names in the table.

If you use Excel there is a free plugin available from MySQL that will let you copy from Excel directly to MySQL, or you can import a file using PHPMyAdmin.

You can also build a form to import a csv file but one if the methods above may be simpler if you only need to do the import once a month. The form needs custom code to validate the data and execute the save.

Bob
abombazza 14 Apr, 2016
Hi bob and thank you for your reply.
I have installed a test form that you have send me last week with a sample for import in database a csv file.
The problem is that i can't mapping a field name of database with columns in the file. How can i do ?
Consider that this form will be use from a user and not by me. So there is a simple page where is possible to import csv files that containt a wedding list.
Can u help me about please?
GreyHead 14 Apr, 2016
Hi abombazza,

How do you plan to tell your users what titles to use for the csv file?

Might it be simpler to let them fill in a form for eaxh item on the list?

Bob
abombazza 14 Apr, 2016
The file is mad up of 5 columns (brand, description, quantity, price, available).
I think is impossibile to load each records in a form because in a wedding list there are many row (about 50 for each), so is better with CSV importer.
After import it the client should be see the wedding list on a single page and book one or more product.
GreyHead 14 Apr, 2016
Hi abombazza,

If those are the fixed column headings then you need to edit the table and column names in the code that I sent you to match these. Your table should also have an auto-incrementing Primary Key column.

Bob
abombazza 14 Apr, 2016
where is the files where insert table in database?
i need to change it for my project .
Thank you bob
GreyHead 14 Apr, 2016
Hi abombazza,

Please check the code that I sent you, the code to save the sata is there.

Bob
abombazza 14 Apr, 2016
this is a backup form (CFV5_FormsBackup_csv_upload.cf5bak).
where is the file (i think php file) where there are sql statement ?
GreyHead 14 Apr, 2016
Hi ambobazza,

Restore the form backup using the Restore icon in the Forms Manager Toolbar, then edit the restored form and you should find a Custom Code action in the On Submit event with the code to check and save the data.

Bob
abombazza 15 Apr, 2016
I have this code on Custom Code:
How can i edit it for save data from csv to database ?

And... i try to find includes folder but i can't find it.

<?php
include (JPATH_SITE.'/components/com_chronoforms5/includes/'.$form->form['Form']['title'].'/on_submit.php');

$file = JPATH_SITE."/components/com_chronoforms5//uploads/test_csv_upload/$file_name.csv";
echo'<div>$file: '.print_r($file, true).'</div>';
?>
This topic is locked and no more replies can be posted.