How to check column labels of CSV file before loading into import set table

dhanu3
Kilo Sage

We want to check csv column headers before loading into import set. We are loading file from RITM to data source and from data source we are loading the file.

For excel using parser and header column we can get details of header. But for CSV there is no such method to get header details.

3 REPLIES 3

Community Alums
Not applicable

Hello @dhanu3 ,

 

Could you please let me know if you got some solution to this ?
I am having some similar requirements where i need to check the column header(s) for a CSV file before importing the same to Import Set Table.

Thanks & Regards,

Pankaj Chakraborty

Hi Pankaj,

 

Yes. I have used below script to read CSV file.

 

var gsa = new GlideSysAttachment();
var bytesInFile = gsa.getBytes('sys_data_source', dataSourceID); // Please enter data source sys id in dataSourceID
var originalContentsInFile = Packages.java.lang.String(bytesInFile); // originalContentsInFile
originalContentsInFile = String(originalContentsInFile);
var ar = [];
ar = originalContentsInFile.split(',');

 

ar will give you content of your file then using for loop and indexof you can read columns.

 

 

Community Alums
Not applicable

Thank you so much. It helped to some extent.