Template for import CSV from job
Views (1177)
Hi there some way to import data from CSV file. The below template could be useful is you not only insert data in a table but for example do some other duty ( example send mail with read data from a table and in csv have the email and foreign key … and so on
static void impCSVFile(Args _args)
{
FormStringControl fileNameControl;
Str 100 codart,G;
CommaIo csvFile;
container readcon;
dialog d = new Dialog();
dialogField df, dfDate;
;
d.addText("name file to import");
df = d.addField(extendedTypeStr(filenameopen),"File NAme");
d.run();
if(!d.closedOk())
return;
csvFile = new CommaIo(df.value(), 'r');
csvFile.outFieldDelimiter(";");
csvfile.inFieldDelimiter(";");
csvFile.outRecordDelimiter("\r\n");
readCon = csvFile.read();
while (csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
//TODO insert here your logic
}
}
This was originally posted here.

Like
Report
*This post is locked for comments