I suggest a new app type in SC of file import. It would be an app that you could select file type, select data table(s), then map fields to tables and save mapping as a template for future use.
That’s great if can be done
Hello,
I could not understand fully your suggestion. It would be an app in which you would select every field from tables that are upload fields for future use, so you wouldn’t have to set which fields are upload fields (and the ones that aren’t) on every new application you create?
regards,
Bernhard Bernsmann
It would be great if SC had an option to IMPORT files instead of only EXPORTING files. I.e. importing a csv, by reading and mapping the fields to a database table and fields. It would be a great enhancement.
PHPRunner has thsi feature by default.
That never is an argument. I left that product with good reason.
I just meant that the import option is included as a default. I am not talking about the product and that’s why I purchased ScriptCase. It will be a good feature to be included in ScriptCase. me for example, I need this option badly and don’t know how to implement it.
If you have an issue reading csv a simple way, I’ll be glad to help. It’s not difficult, in fact it’s deadly simple. The following sample reads a csv of members and load it into a database.
$cnt=0;
$handle = fopen('D:/Program Files (x86)/NetMake/v6/wwwroot/scriptcase/file/doc/csvupload/'.{csv}, 'r');
if ($handle)
{
set_time_limit(0);
//the top line is the field names
$fields = fgetcsv($handle, 4096, ';');
$empty='';
//loop through one row at a time
while (($data = fgetcsv($handle, 4096, ';')) !== FALSE)
{
$data = array_combine($fields, $data);
if($data['Geboortedatum']=='') {$data['Geboortedatum']='01-01-1900';}
$stm ='replace into lid (LidId,Voornaam,Voorletters,Voorvoegsels,Achternaam,'
. 'Straat,Huisnummer,Postcode,Woonplaats,Geboortedatum,Geslacht,'
. 'EMail,TelefoonVast,TelefoonMobiel,LidSinds) values ('
. '"'.$data['Lid-nr'].'",'
. '"'.$data['Voornaam'].'",'
. '"'.$empty.'",'
. '"'.$empty.'",'
. '"'.$data['Naam'].'",'
. '"'.$data['Straat'].'",'
. '"'.$empty.'",'
. '"'.$data['Postcode'].'",'
. '"'.$data['Woonplaats'].'",'
. 'STR_TO_DATE("'.$data['Geboortedatum'].'","%e-%m-%Y"),'
. '"'.$data['Geslacht'].'",'
. '"'.$data['E-mail'].'",'
. '"'.$empty.'",'
. '"'.$data['GSM'].'",'
. 'STR_TO_DATE("'.$data['Lid vanaf'].'","%e-%m-%Y"))';
sc_exec_sql($stm);
$cnt++;
}
fclose($handle);
}
{reccnt}=$cnt;
Explanation. Our current software that is in production has the ability that when we get a new customer that sends us a .csv of data for us to work, we use an app within our software that is called ‘Customer data mapper’. It allows us to map the .csv columns to certain db tables and columns and omit un-needed .csv columns. We then save this data map as a template for future use for when that customer sends us more data to upload to our db. In most cases, the .csv from the customer always has the same data columns so we just re-use the saved data map for that customer. Various customers send us files in various different data columns in the .csv’s so we create a map template for each customer for our future use.
We are re-building our (extensive) software using ScriptCase and will soon have to create this feature.
Mark Stopkey
Well if you use the first row containing the fieldnames then you can use this to generate the correct insert/replace. The only thing you need to do is to make the fieldnames in the first csv row match the database fields. The sequence is than of no issue as getcsv can do this for you and generates an associative array. If the csv has no first header record then you need to apply one. But if you have already php code ready for this task then you can simply reuse it in SC?
Hello guys,
I have sent this suggestion to our development team.
Notice that you can achieve it with a bit of programming also.
regards,
Bernhard Bernsmann
Yes Bernard, in fact you can achieve anything of scriptcase with a bit of programming But your customers are lazy, they want to generate it (lol)
Our current software is built on Adempiere, all compiled Java. Thanks for the info.
Mark Stopkey