How to load .txt file in data source and transform it please any help is appreciated

ABHAY_M
Tera Guru

find_real_file.png

 this is the sample data of text file  first coloumn represents location field and second column asset tag how to load this data in data source if parsing then how do i parse with script 

Thank you 

1 ACCEPTED SOLUTION

Jon23
Mega Sage

One approach is to use the 'Custom (Parse by Script)' format for a data source.

Based on the file you provided, the following parsing script can be used in the data source:

Parsing Script

// The input value can be accessed through the variables named "line", "lineNumber" and "result"
// The function uses result variable to return parse result back. 
(function(line, lineNumber, result) {

    var map = {};
    var items = line.split("|");
    map['location'] = items[0];
    map['asset'] = items[1];
    result.addRow(map);

})(line, lineNumber, result);

Data Source Record

find_real_file.png

 

 

View solution in original post

13 REPLIES 13

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

txt file is not supported out of the box.

possibly you will have to write custom script to get the txt file content and then transform it

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

i have added image of  the above sample data how do i tranform it unable to figure out

Hi,

I would suggest to use CSV file

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader