我正在尝试从Microsoft的地理生命轨迹数据集中获取“步行”运输模式。我已经编写了代码,并且能够获取一些文件,但是并未显示包含walking的所有plt文件。 这是我的代码
import os
path='/Users/karnny/Desktop/Project/Geolife Trajectories 1.3/Data/052/labels.txt'
walklist=[]
file = open(path,'r').read()
print(file)
splitn=file.split('\n')
splitt=[]
count = 0
for eachline in splitn:
#print("eachline "+eachline)
splitt=eachline.split('\t')
#print(splitt)
if len(splitt)>2 and splitt[2]=='walk':
pltwalk=''
splitname=splitt[0].split(' ')
date=splitname[0].split('/')
time=splitname[1].split(':')
pltwalk=date[0]+date[1]+date[2]+time[0]+time[1]+time[2]+'.plt'
#print(pltwalk)
walklist.append(pltwalk)
print("Walklist")
for walkname in walklist:
print(walkname)
print(count)
rootDir = '/Users/karnny/Desktop/Project/Geolife Trajectories 1.3/Data/052/Trajectory/'
for dirName, subdirList, fileList in os.walk(rootDir):
print('Found directory: %s' % dirName)
for fname in fileList:
#print('\t%s' % fname)
if fname in walklist:
print(fname)
labels.txt中的开始时间似乎与.plt的文件名不匹配。 Labels.txt