如何从 dropbox 中读取 csv 文件作为字典(从 csv.DictReader() 读取)?

how to read csv file from dropbox as a dictionary (as read from csv.DictReader() )?

我正在尝试使用

从保管箱中读取 csv 文件

md, res = dbx.files_download(path)

按照本 link 中的建议
这是我正在尝试阅读的 csv:csv_file_image
res.content,我从形状丑陋的 csv 文件中获取数据。
有没有什么方法可以读取更多形状的数据,比如使用:

import csv
with open(file) as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        print(row['name'])

我想将 csv 文件作为字典阅读,但我得到的只是数据:response_data_image

我通过将 res.content 转换为可迭代对象找到了这个解决方案:

import csv
import dropbox

path = '' # file path which is needed to be read
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
md, res = dbx.files_download(path)
data = res.content # data in ugly shape
# Now data is needed to be decoded from bytes to unicode and then str.split()
data = data.decode('utf-8')
data = data.split('\n')
# Now data is an iterable object, so csv.DictReader can be used
reader = csv.DictReader(data)
# Loop to get data using key value from reader dict
for row in reader:
    row['nameen']    # 'nameen' is the key value in my case