小编All*_*son的帖子

Python CSV阅读器TypeError:字节对象上的字符串模式

我想第一次使用python CSV阅读器.我有一个方法要求用户选择他们想要解析的文件,然后它将该文件路径传递给parse方法:

def parse(filename):
        parsedFile = []
        with open(filename, 'rb') as csvfile:
                dialect = csv.Sniffer().sniff(csvfile.read(), delimiters=';,|')
                csvfile.seek(0)
                reader = csv.reader(csvfile, dialect)

                for line in reader:
                    parsedFile.append(line)
                return(parsedFile)

def selectFile():
        print('start selectFile method')
        localPath = os.getcwd() + '\Files'
        print(localPath)
        for fileA in os.listdir(localPath):
                print (fileA)

        test = False
        while test == False:
                fileB = input('which file would you like to DeID? \n')
                conjoinedPath = os.path.join(localPath, fileB)
                test = os.path.isfile(conjoinedPath)


        userInput = input('Please enter the number corresponding to which client ' + …
Run Code Online (Sandbox Code Playgroud)

python csv attributeerror python-3.x

2
推荐指数
1
解决办法
1094
查看次数

标签 统计

attributeerror ×1

csv ×1

python ×1

python-3.x ×1