Inbound csv import starting at a specific row
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 10:33 AM
I have an inbound action that is creating a data source from a csv
On import I have the inbound action set to current.header_row = 5
I would expect the import to start from row 5 as header and then import the data from row 6 onward, however it keeps failing and is trying to still import the data in the csv file from row 1
My csv file has 4 title rows and the header row is actually on row 5
I need to ignore the files title rows and start the import from header row 5 and then the data is in rows 6-### (can be any number of rows that follow the header
This file comes from an automated system
The first 4 rows have report information
The actual data that I need to transform starts at row 5 (header row)
Any ideas how I can achieve this?
Thank you
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 08:55 AM
current.type = "File";
//current.format = "Excel"; // For Excel Files
current.format = "CSV"; // For CSV Files
current.header_row = 5;
current.sheet_number = 1;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2018 10:59 AM
Can you provide the entire inbound email action Script in case there is something else there causing this to fail?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 07:38 AM
Here is the complete inbound action script
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var vmh_number = get_vmh_data();
function get_vmh_data(){
var gr = new GlideRecord('u_vendor_management_history');
gr.u_name = email.subject + " "+email.from; //email.from gs.nowDateTime()
gr.insert();
gs.log('VMH record created. The number is '+gr.u_number);
//return gr.u_number;
}
var importSetTableName = "u_vendor_management_cis_load";
var transformMapIDs = "1763f9754fda4bc0459e0f5d0210c709"; //Use a comma to specify multiple transform maps
//test sysid 46037f6b4f6f4300becb9efd0210c771
//var transformMapIDs = "46037f6b4f6f4300becb9efd0210c771";
var applicatonScope = "Global";
// Create the datasource record
current.name = "File import from: " + email.from; //Feel free to rename this as appropriate
current.import_set_table_name = importSetTableName;
current.file_retrieval_method = "Attachment";
current.type = "File";
//current.format = "Excel"; // For Excel Files
current.format = "CSV"; // For CSV Files
current.header_row = 5;
current.sheet_number = 1;
current.sys_package.setDisplayValue(applicatonScope);
current.sys_scope.setDisplayValue(applicatonScope);
var dataSourceID = current.insert();
gs.log("THIS is the import email script");
/*
* Schedule Load of Attachment
*
* This inbound email action will generate an import data source, however the attachment isn't copied to the data source until
* after the insert of the record. Scheduling the import to happen 30 seconds later so that attachment has time to be copied.
*/
new global.EmailFileImportUtils().scheduleImport(dataSourceID, transformMapIDs);
})(current, event, email, logger, classifier);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 09:05 AM
When you manually loaded the initial file and set the header row to 5 did that work? You have to do this first and then you set up the maps, inbound action script, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 10:06 AM
Did that and still not working
Created and loaded data from csv file header row 5
Created transform map
Transformed data
Created inbound action
Set import set table and transform map used in manual load
Sent in email with attachement (same file used for manual load)
Transform History
2 records both error code 800
Unable to resolve target record, coalesce values not present: u_system_deviceid
Even though the headere row is set to 5 the inbound transform is using row 1 of the file to start the transform and creates fields
This is a csv file and I cant seem to work around this
The file cannot be changed from the source either
Manually it works as expected but not from the inbound action
worker.7 Altering storage table [tmp_u1649610223t]: ALTER TABLE tmp_u1649610223t ADD `u_company_` VARCHAR(40)
worker.7 Altering storage table [tmp_u1085692250t]: ALTER TABLE tmp_u1085692250t ADD `u_wmp` VARCHAR(40) |