im making a program to transfer .nc files to .csv files. This is the error I have and I am unsure how to fix it.
ive googled the issue and I cant find something that fits this, sorry
import os,sys
folder =("C:/Users/workexp/Downloads/weather.nc", "r")
for filename in os.listdir(folder):
infilename = os.path.join(folder,filename)
if not os.path.isfile(infilename): continue
oldbase = os.path.splitext(filename)
newname = infilename.append('.nc,.csv')
output = os.rename(infilename, newname)
expected to output file in a .csv but im stuck on this issue, thanks guys
Below code takes all the files in the 'Downloads' folder, checks if its has a .nc extension, and changes the filename to .csv
import os,sys
folder = "C:/Users/workexp/Downloads"
for filename in os.listdir(folder):
if os.path.isfile(filename):
file_name, file_extension = os.path.splitext(filename)
if file_extension == '.nc':
os.rename(filename,file_name+'.csv')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.