I have an requirement to convert the source JSON file data into Binary format base6. I tried with Copy activity/binary dataset or using dataflow but converting the complete file data is not possible. Is there any way we can achieve this? Or is there any databricks notebook code we can use to convert the file? I have mounted the blob storage file into notebook and using the same.
I am using this code to convert the data into binary but it is not working.

Collect gives you a list of records, but the list doesn't have the function
encode. So, you need to take only the data from the list and encode it. Below are the different ways you can encode.Output:
You are trying using
spark.read.text; this creates records for each line and you need to loop through all records and convert them to binary. Instead of that, you can usesc.binaryFiles('path'), which creates records for each file with the whole file data in binary format like below.Output:
Or
Here, make sure you give the file path with a
/dbfsprefix to the mount path.Output: