Im receiving the below error when attempting to write to a CSV file. I checked my file and folder settings and global availability is set. How do I fix this? Code is below as well.
I have tried with both open and closed files.
File "c:\Users\toril\OneDrive\Documents\Pokemon AI\base 1 test.py", line 19, in <module>
with open ('pokemontest1.csv', 'w', newline='') as csv_file:
PermissionError: [Errno 13] Permission denied: 'pokemontest1.csv'
from importlib.resources import Resource
from string import capwords
from unicodedata import name
from pokemontcgsdk import RestClient
from pokemontcgsdk import Card
from pokemontcgsdk import Set
from pokemontcgsdk import Type
from pokemontcgsdk import Supertype
from pokemontcgsdk import Subtype
from pokemontcgsdk import Rarity
from pokemontcgsdk import querybuilder
from pokemontcgsdk import RestClient
import csv
RestClient.configure('xxxxxxxxxxxx')
fields = ['Data']
with open ('pokemontest1.csv', 'w', newline='') as csv_file:
Cards = Card.where(q='set.name:generations supertype:pokemon')
for card in Cards:
rows = [card.name, card.types, card.supertype, card.subtypes, card.number, card.rarity, card.nationalPokedexNumbers, card.id, card.set.name, card.set.series]
csvwriter = csv.writer(csv_file)
csvwriter.writerow(fields)
csvwriter.writerows(rows)