Creating NFTs from CSV Data with Python and Pandas

I'm stuck trying to make NFTs using a CSV file and Python. I've been following a guide, but I'm having trouble with my code. Can anyone help me figure out what's wrong?

Here's what I've got so far:

```python
import pandas as pd
import random

def create_random_nft(nft_id):
    nft_name = f"CryptoArt_{nft_id}"
    attributes = {
        'id': nft_id,
        'background': random.choice(['blue', 'red', 'green']),
        'feature': random.choice(['star', 'moon', 'sun']),
        'shape': random.choice(['circle', 'square', 'triangle'])
    }
    return [nft_name] + list(attributes.values())

def check_duplicate(nft_data):
    df = pd.read_csv('nft_database.csv')
    query = ' & '.join(f"{k} == '{v}'" for k, v in zip(df.columns[2:], nft_data[2:]))
    return not df.query(query).empty

test_nft = create_random_nft(1001)
print(f"Is duplicate: {check_duplicate(test_nft)}")

I’m getting errors when I run this. Can someone point out what I’m doing wrong? Thanks in advance!

hey bro, looks like ur code’s pretty close! one thing i noticed - ur not actually writing the nfts to the csv file. try adding a function to append new nfts to the csv after generating them. also, make sure ur csv file exists b4 trying to read it. good luck with ur project man!

hey there! your nft project sounds super interesting! :blush: i’m curious, have u thought about how you’re gonna handle the uniqueness of each nft? like, what happens if you generate two that are exactly the same? :thinking:

also, i noticed you’re using pandas - that’s cool! but maybe overkill for this? u could probably just use the csv module and it might be simpler. what made u choose pandas?

oh, and one more thing - are u planning to add more attributes later? it might be fun to have some really rare combinations to make some nfts extra special! :star2:

keep us updated on how it goes! can’t wait to see what u create!

In my experience, the issue often stems from assuming that the CSV file exists with a matching structure. It helps to verify that the file is actually created beforehand and that its headers correspond to the attributes generated in your code. It might be beneficial to wrap CSV read operations in a try-except block to capture any FileNotFoundError. Additionally, rather than reading from the CSV each time you check for duplicates, loading the data once and reusing it can improve efficiency. Finally, remember to add functionality that writes new NFT data to the CSV.