- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 12:56 AM
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
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 04:38 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 01:59 AM
Hi @Jon23 ,
Do you have idea, on what to use if I will retrieve the data start from row 15. My column header starts in row 14.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 05:24 AM
Hi @Xhare
You should be able to wrap the code with an 'if' and not start processing until the lineNumber is reached. For example:
// 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) {
if (lineNumber > 13) { // <<<lineNumber starts at 0
var map = {};
var items = line.split(",");
map['UserName'] = items[0];
map['LastName'] = items[1];
map['FirstName'] = items[2];
map['MiddleName'] = items[3];
map['Organization'] = items[4];
result.addRow(map);
}
})(line, lineNumber, result);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 12:09 AM
Hi @Jon23 ,
I'm using below script, but still getting data from row 1 until the end of row.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 11:29 AM
Can you check your end of line (EOL) characters on the file?
Depending on the system creating the file it could be a line feed which may be causing the issue. If it is, try converting EOL to carriage return/line feed.