maybe try w+ instead of w? Like this:
import csv
with open('mycsv.csv', 'w+') as f:
writer = csv.writer(f)
writer.writerow(['col1', 'col2', 'col3'])
writer.writerow(['one', 'two', 'three'])`
w+ forces python to create a new file if that file doesn't exist yet.
Answer from Matthijs990 on Stack OverflowBrand new to vscode. How do you export results into a CSV?
Cannot create csv file from python in visual studio code - Stack Overflow
New to using Python with VS Code and need help with CSV files
Do I need to download plugins in VSCode to use csv files?
I'm trying to pull some data for a work project and export it into a csv file, but I have literally no idea how. I'm running sql queries, and I've got all of the data coming through in the results tab, but I can't find a way to export this data. Any advice?
maybe try w+ instead of w? Like this:
import csv
with open('mycsv.csv', 'w+') as f:
writer = csv.writer(f)
writer.writerow(['col1', 'col2', 'col3'])
writer.writerow(['one', 'two', 'three'])`
w+ forces python to create a new file if that file doesn't exist yet.
If you're working in a virtual environment, the script is creating the file in a different folder, look for the folders above.
So I made a simple chart thing using matplotlib and pandas and it all works well in PyCharm.
I copied the same code over to VS Code and also moved the .CSV file to the same folder where my .py is, for some reason VS Code doesn't see the file and tells me it doesn't exist. How do I fix it? Maybe I need to install a plugin for it? I just don't know how VS Code works at all xd