I'm building a database that stores csv files and presents them when a user selects the csv he/she wants to visualize. The problem is, whenever I open the csv file from the database the resulting dataframe is garbage
models.py
class Csv(models.Model):
file_name = models.FileField(upload_to='csvs', max_length = 100)
public = models.BooleanField(default = False)
user = models.ForeignKey(User, on_delete = models.CASCADE, null = True)
name = models.CharField(max_length = 100)
library = models.CharField(max_length = 100, null = True)
def __str__(self):
return "File id: {}".format(self.id)
views.py
def test(request):
csv = Csv.objects.get(id = 5)
df = pd.DataFrame(csv.file_name)
print(df.head())
return render(request, 'mainproj/test.html', {'df' : df.dtypes})
Test_Data.csv
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…