public static function trim($filepath, $delimiter)
    {
        $tmpFile = tmpfile();
        $uploaded_fh = fopen($filepath, "r");
        
        if ($uploaded_fh)
        {
            while (!feof($uploaded_fh))
            { 
                $lineArray = fgetcsv($uploaded_fh, 0, $delimiter);
                
                if (!empty($lineArray))
                {
                    foreach ($lineArray as $index => $value)
                    {
                        $lineArray[$index] = trim($value);
                    }
                    
                    fputcsv($tmpFile, $lineArray, ",");
                }
            }
            
            fclose($uploaded_fh);
            
            $meta_data = stream_get_meta_data($tmpFile);
            $tmpFileName = $meta_data["uri"];
            rename($tmpFileName, $filepath); # replace the old upload file with new.
        }
        else
        {
            throw new \Exception("Failed to open upload file for trimming.");
        }
    }