如何在python中传递csv文件的第一列(How to pass the first column of a csv file in python)
我刚写了这段代码:
EXl = ('C:\\vd36e404.vdb','C:\\vd368c03.vdb') x=0 for x in EXl: import os filesize= os.path.getsize(x) print (filesize);我想做的是这个。 我有一个csv文件,它在第一列中有我需要给上面程序的路径列表,然后它应该给我输出csv文件给出的路径文件的大小。
有谁知道如何编码?
I have just written this code:
EXl = ('C:\\vd36e404.vdb','C:\\vd368c03.vdb') x=0 for x in EXl: import os filesize= os.path.getsize(x) print (filesize);What I would like to do is this. I have a csv file which has in the first column the list of path I need to give to the above program, which should then give me as output the size of the path-file given by the csv file.
Does anyone know how to code that?
最满意答案
我认为这适合你:
http://docs.python.org/library/csv.html
看看这个例子:
import csv spamReader = csv.reader(open('eggs.csv', 'rb'), delimiter=' ', quotechar='|') for row in spamReader: print ', '.join(row) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful SpamI think this would fit you :
http://docs.python.org/library/csv.html
Look at this example :
import csv spamReader = csv.reader(open('eggs.csv', 'rb'), delimiter=' ', quotechar='|') for row in spamReader: print ', '.join(row) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful Spam更多推荐
发布评论