[英]input Csv models.FileField into pandas object
I have model Field instance.我有模型 Field 实例。
myCsv = myFile.objects.get(id=1) // myCsv.document is models.FileField
and want to put this in pandas.并想把它放在熊猫中。
df = pd.read_csv(thred.document.read())
OSError: Expected file path name or file-like object, got <class 'bytes'> type
How can I put the cev file to pandas object??如何将cev文件放入pandas对象?
Probably you can try like this:也许你可以这样尝试:
thred = myFile.objects.get(id=1)
df = pd.read_csv(thred.document.path)
More information regarding path can be found in documentation
on how to manage files in FileField
(or ImageField
).有关路径的更多信息可以在有关如何管理
FileField
(或ImageField
)中的documentation
找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.