How to read CSV data as array pairs in Magento 2?

You can Retrieve CSV file data as pairs by just calling the Magento\Framework\File\Csv class. A Csv.php class contains the getDataPairs() function to convert the first column as a key and the second column as the value in the array from the CSV file.

This article is helpful if you have a CSV file with only two columns and want to treat it as an array key-value pair.

Let’s assume your CSV file contains below value for the first column and a second column with comma-separated,