如何获取python代码(Spyder)来查找和提取数据文件?

时间:2018-12-19 13:30:40

标签: python file file-location

我正在做材料科学中的机器学习项目,此代码要求我选择要上传的文件,但是当我命名文件时,它会显示一条错误消息。代码的开头(和相关位)如下:

API 28

这是我收到的错误消息:

import xlrd
import re
import numpy
from sklearn import svm
from sklearn import preprocessing
from sklearn import tree
from sklearn.ensemble import RandomForestClassifier
import random
import os
from xlutils.copy import copy
import xlsxwriter
import graphviz


def main():

    pastExperiments = StoredData()
    response = input('Do you wish to use continuous representation of discreet data if available data? y or n\t')
    if response == 'y':
        pastExperiments.useContinuousRepresentation = True
    else:
        pastExperiments.useContinuousRepresentation = False

    response = input('Do you want to choose import data? y or n\t')
    if response == 'y':

        while response == 'y':
            nameOfFile = input('What is the name of the file you wish to import.\t')
            pastExperiments.importFile('./Input/' + nameOfFile)
            response = input('Do you wish to import additional data? y or n\t')
        #At this point all training data should have been imported.

    else:
        folder = os.fsencode('Input')
        for inputFile in os.listdir(folder):
            fileName = os.fsdecode(inputFile)
            if fileName.endswith(".xlsx"):
                pastExperiments.importFile('./Input/' + fileName)
            else:
                continue

谢谢!

0 个答案:

没有答案