如何修复ID为“ 3 / Ewurafua / processed.cleveland.data.csv”的csv上传。也许它被删除了?

时间:2019-09-12 08:35:35

标签: python django csv django-models

我正在尝试使用github上的tomwalker django-quiz-app开放源代码库在django管理站点上上传csv文件,当它告诉我上传成功时,但是当我尝试访问上传的文件时,它给出一个错误。

 def csv_upload_post_save(sender, instance, created, *args, **kwargs):
  if not instance.completed:
    csv_file = instance.file
    decoded_file = csv_file.read().decode('utf-8')
    io_string = io.StringIO(decoded_file)
    reader = csv.reader(io_string, delimiter=';', quotechar='|')
    header_ = next(reader)
    header_cols = convert_header(header_)
    print(header_cols, str(len(header_cols)))
    parsed_items = []

    '''
    if using a custom signal
    '''
    for line in reader:
        # print(line)
        parsed_row_data = {}
        i = 0
        print(line[0].split('\t'), len(line[0].split('\t')))
        row_item = line[0].split('\t')
        for item in row_item:
            key = header_cols[i]
            parsed_row_data[key] = item
            i+=1
        # create_user(parsed_row_data) # create user
        parsed_items.append(parsed_row_data)
        # messages.success(parsed_items)
        print(parsed_items)
    csv_uploaded.send(sender=instance, user=instance.user, csv_file_list=parsed_items)

    instance.completed = True
    instance.save()


   post_save.connect(csv_upload_post_save, sender=CSVUpload)

我希望能够查看该文件,因为它表明上传成功,但是可以打印出来       “ ID为3 / Ewurafua / processed.cleveland.data.csv的csv上传”没有       存在。也许它被删除了?”。

0 个答案:

没有答案