Solved

Microsoft api - multiple filters and finding column count of csv file

  • 4 August 2023
  • 1 reply
  • 33 views

Hi,

  1. I have an use case where I should search for files in sharepoint library and filter files that start with ABC and the file type as CSV. I have the below GET command but I am not sure how to add another filter that picks only the CSV files.

    https://graph.microsoft.com/v1.0/sites/company.sharepoint.com,U265b60,346a1581/drives/driveid/root/children?select=name,@microsoft.graph.downloadUrl&filter=startswith(name,'ABC')

  2. Using the above @microsoft.graph.downloadUrl I have another http that downloads the file content and pass on to target. I need to check the number of columns before I write into target to avoid any failure. is there any way to find the number of columns present in the csv file?

Any help please?

icon

Best answer by Sanjeev 7 August 2023, 03:51

View original

1 reply

Userlevel 2
Badge

@anand_rajan your first question is really for the API vendor(Microsoft).

For the second question, if the requirement is to process only specific columns/fields then you can use the Field Remover processor and use the ‘keep listed fields’ option. If for some reason you need the count of columns then it can be easily done via Groovy Evaluator processor with a script like below:

for (record in records) {
input = record.value
num_cols = input.keySet().size()
record.value['col_count'] = num_cols
sdc.output.write(record)
}

 

Reply