读取csv文件: def readCsv(): rows=[] with file(r'E:\py\py01\Data\system.csv','rb') as f: reads=csv.reader(f) for i in reads: rows.append(i) print rows return rows写入csv文件: def writer(): with file(r'E:\py\py01\Data\system.csv','wb') as f: writer=csv.writer(
看很多资料,很少有讲怎么去操作读写csv文件的,我也查了一些.很多博客都是很老的方法,还有好多转来转去的,复制粘贴都不能看.下面我在这里归纳一下,以免以后用到时再费时间去查.前端实现文件下载和拖拽上传 通过sc.textFile val input = sc.textFile("test.csv") val result = input.map { line => val reader = new CSVReader(new StringReader(line)); reader