Separate CSV file reading and BG reading extraction.

Read all the rows from the CSV file then close it.
Afterwards extract the BG values.