| 
 
	积分16贡献 精华在线时间 小时注册时间2017-12-30最后登录1970-1-1 
 | 
 
| 
请问一下我用一下代码读取csv文件,但是最后的slope print出来是第一个文件得出数据的死循环,请问一下为什么,怎么解决??
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  
 import csv
 import glob
 import os
 import math
 import numpy as np
 
 input_path="E:\maven\data\sci\ngi\l2\2017\01\*.csv"
 files_path= glob.glob(r'E:\maven\data\sci\ngi\l2\2017\01\*.csv')
 co2_abundance=[]
 orbit=[]
 alts=[]
 slope=[]
 Temperature=[]
 print(files_path)
 for file_path in files_path:
 with open(file_path,'r')as csv_in_file:
 filereader=csv.reader(csv_in_file)
 header=next(filereader,None)
 for row in filereader:
 specics=row[13]
 if specics=='CO2':
 if row[15]!=' ':
 alts.append(row[7])
 co2_abundance.append(row[15])
 
 new_alts=[]
 new_abundance=[]
 for alt in alts:
 if alt!=0:
 alt=float(alt.strip())*10**(5)
 alt=1/alt
 new_alts.append(alt)
 
 for abundance in co2_abundance:
 if abundance!=0:
 abundance=float(abundance.strip())
 abundance=math.log(float(abundance))
 new_abundance.append(abundance)
 
 new_alts=np.array(new_alts)
 new_abundance=np.array(new_abundance)
 sp=np.polyfit(new_alts[:100],new_abundance[:100],1)
 slope.append(sp[0])
 
 | 
 |