Data-driven testing with different data sets for each request

Hi @vdespa
Hope you are doing well.
I have watched your video on YouTube. You deliver great content. Now I need your help. Here I have to make some changes in your pre-request script.
I have CSV file with a lot of request data(rows), and columns as variables.

First request should be run one time(has no data defined), second request should get data from the file and iterate with count of it. Then again the same . Collection will contain many requests, but the main logic is the same.

// Load data from file
if (typeof pm.variables.get('requestsData') !== 'object') {
    pm.variables.set('requestsData', pm.iterationData.toObject());
}
const requestsData = pm.variables.get('requestsData');

if (typeof requestsData !== 'object' || Object.keys(requestsData).length === 0) {
    console.log('No external data provided or object is empty.');
    return;
}

// Find the current request
const currentRequest = requestsData.requests.filter(({name}) => name === pm.info.requestName)[0];

// Skip the rest since we have no data
if (!currentRequest) {
    console.log(`Request ${pm.info.requestName} has no data defined.`);
    return;
}

// Expose variables
const variables = currentRequest.data.shift();

for (const [key,value] of Object.entries(variables)) {
    pm.variables.set(key, value);
}

pm.variables.set('requestsData', requestsData);

// Decide where to go next
if (currentRequest.data.length > 0) {
    postman.setNextRequest(pm.info.requestName);
}

This is your pre-request script from the mentioned YouTube video, how can I change and use it in my case? I am not much experienced that is why I expect your help :upside_down_face:

Handling such scripts is not easy.

I recommend understanding the concepts around JavaScript, Postman variables and Postman workflows.

Begin with some JavaScript basics:

Okay, thanks
I will try to do my best and will let you know about my progress.