Skip to main content

I need to read a specific header and the headers position will be different for different sheets. But in AA we can use the Header Name but im trying to achieve to fetch a header values where Header name starts with “Last”. 

 

Kindly suggest a workaround for this?

Hey,

What you can do is read the first row, use string condition to find “Last”, also use a counter and then use loop for that whole first row. Increment for every iteration “Last” is not found. Once found then break and use the counter to read the row using index value.

Let me know if you require any further assistance.

 


You can do what Zaid said. The easier solution is to utilize the record function in AA. You may have to convert your .csv to an .xlsx. Then what you do is utilize the excel command loop through  each row in a worksheet. In the loop setup you can define a record variable which will allow you to call a value in that record by the column header. The key here is when you open the excel file you need to select “sheet contains headers”


What if the Header name is Last Name or Last Record. Will that pick if the word contains Last? 


Actually i tried that it didnt worked throwing as below

Key 'Last' not found in record.

 

Since the header might be start with Last i tried but in header the value is Last Name or sometimes it might be Last Record or other words which start with Last.


Actually i tried that it didnt worked throwing as below

Key 'Last' not found in record.

 

Since the header might be start with Last i tried but in header the value is Last Name or sometimes it might be Last Record or other words which start with Last.

You can use string includes to check


Ah ok. So the record variable is a dictionary type variable where the key must match perfectly in order to be used. When I read your paragraph I thought the column header was just named “Last”. If you have multiple column headers with last in it you have two options. Option 1 is you can create a list type variable with all of the different column names you want to get values from. You can keep similar code and just create a nested loop with an if statement in it. For each row in a worksheet → for each item in a list → if (string condition record(list item) includes “Last” then get value. Option 2 is to rename the columns but I know that’s not always possible. 


Reply