In order to fetch the execution context, use the ‘N/runtime’ module.
Use the runtime.executionContext property to determine the execution context of a script.
To check whether the execution context is CSV, write the code below.
let isCsvContext = runtime.executionContext === runtime.ContextType.CSV_IMPORT;
If the execution context is CSV, the value of isCsvContext will be true; otherwise, it will be false.