我有一个很大的csv文件,其中第一列是一年中的第几天,第二列是以分钟为单位的时间(即00:00):测量年份= 2010
1,0,2.701,104.3,5.02,2.985,13.71,645.97,1018.9,6.249,4.166,.501
1,1,2.701,104.3,5.02,2.985,13.71,645.97,1018.9,6.249,4.166,.501
1,2,2.737,104.3,5.228,3.006,13.71,645.97,1018.9,6.249,4.166,.518
1,3,2.805,104.3,4.958,3.027,13.71,645.97,1018.8,7.08,3.749,.767
1,4,2.821,104.3,4.999,3.006,13.71,645.97,1018.9,7.08,4.166,.79
1,5,2.847,104.2,5.208,3.048,13.72,645.97,1018.9,6.249,4.166,.567
1,6,2.881,104.2,4.853,3.027,13.71,645.97,1018.7,6.666,4.166,.688
Run Code Online (Sandbox Code Playgroud)
我想在R中使用datetime类合并第1列和第2列,这样我就可以从2010-01-01 00:00:00开始获得一个列
干杯,纳文
刚刚写了我的第一个python程序!我在邮件中将zip文件作为附件保存在本地文件夹中.该程序检查是否有任何新文件,如果有的话,它会提取zip文件,并根据文件名提取到不同的文件夹.当我运行我的代码时,我收到以下错误:
回溯(最近调用最后一次):文件"C:/Zip/zipauto.py",第28行,用于new_files中的文件:TypeError:'NoneType'对象不可迭代
任何人都可以告诉我哪里出错了.
非常感谢你的时间,
Navin这是我的代码:
import zipfile
import os
ROOT_DIR = 'C://Zip//Zipped//'
destinationPath1 = "C://Zip//Extracted1//"
destinationPath2 = "C://Zip//Extracted2//"
def check_for_new_files(path=ROOT_DIR):
new_files=[]
for file in os.listdir(path):
print "New file found ... ", file
def process_file(file):
sourceZip = zipfile.ZipFile(file, 'r')
for filename in sourceZip.namelist():
if filename.startswith("xx") and filename.endswith(".csv"):
sourceZip.extract(filename, destinationPath1)
elif filename.startswith("yy") and filename.endswith(".csv"):
sourceZip.extract(filename, destinationPath2)
sourceZip.close()
if __name__=="__main__":
while True:
new_files=check_for_new_files(ROOT_DIR)
for file in new_files: # fails here
print "Unzipping files ... ", file
process_file(ROOT_DIR+"/"+file)
Run Code Online (Sandbox Code Playgroud)