Through following code we can read CSV files
static void ReadCsvFile(Args _args)
{
#File
IO iO;
CustAccount custAccount;
CustName custname;
FilenameOpen filename = "d:\\jit.csv";//To assign file name
Container record;
boolean first = true;
;
iO = new CommaTextIo(filename,#IO_Read);
if (! iO || iO.status() != IO_Status::Ok)
{
throw error("@SYS19358");
}
while (iO.status() == IO_Status::Ok)
{
record = iO.read();// To read file
if (record)
{
if (first) //To skip header
{
first = false;
}
else
{
custAccount = conpeek(record, 1);//To peek record
custname = conpeek(record, 2);
info(strfmt('%1--%2',custAccount,custname));
}
}
}
}
Happy X++ coding!!!
in this code how can I check existing records that should not be inserted from .csv file
ReplyDeletehow to import CSV with a large description with Multiple lines?
ReplyDelete