Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个_csv.reader类型对象,它是由从 API 收集数据的函数创建的。我将如何打开和解析这种类型的对象,以便在 Pandas 等中进行处理?
_csv.reader
该对象最初是这样创建的:
obj = csv.reader(io.BytesIO(Results.encode('ascii', 'replace')), delimiter='\t')
更改为 StringIO 有效。我相信由于编码而使用了 BytesIO,可能是为了忽略希腊字符?
以 io.StringIO(Results) 作为文件:csv_reader = csv.reader(file, delimiter='\t') for row in csv_reader: print(row)