代码拉取完成,页面将自动刷新
同步操作将从 Yiman/VisualizationProject 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import re
"""
:param 清洗文件路径
:return 按时间顺序排列好的文件路径名
"""
def filter_file_path():
all_file = []
for i in os.walk('./data/stu_data'):
all_file.append(i)
dir_name = all_file[0][1]
max_compare_times = 3
dir_name = sort_by_date(dir_name, max_compare_times)
all_file = all_file[1:]
month_data_name = []
final_month_name = []
file_with_path = []
for i in all_file:
month_data_name.append(i)
for i in month_data_name:
final_month_name.append(i[-1])
dir_len = len(dir_name)
max_compare_times = 4
for i in range(0, dir_len):
final_month_name[i] = sort_by_date(final_month_name[i], max_compare_times)
for i in range(0, len(dir_name)):
for j in range(0, len(final_month_name[i])):
final_month_name[i][j] = './data/stu_data/' + str(dir_name[i]) + '/' + str(final_month_name[i][j])
file_with_path = file_with_path + final_month_name[i]
return file_with_path
"""
:param 用正则,选择排序
:return 按日期排序好的列表
"""
def sort_by_date(data, times):
# 文件夹路径不同,选择不同匹配模式
patt = '(\d+)-(\d+)' if times == 3 else '(\d+)-(\d+)-(\d+)'
# 交换排序
for i in range(len(data) - 1):
for x in range(i + 1, len(data)):
j = 1
while j < times:
lower = re.search(patt, data[i]).group(j)
upper = re.search(patt, data[x]).group(j)
# print lower,upper
if int(lower) < int(upper):
j = times
elif int(lower) == int(upper):
j += 1
else:
data[i], data[x] = data[x], data[i]
j = times
return data
if __name__ == '__main__':
file_name_with_path = filter_file_path()
for i in file_name_with_path:
print(i)
print('count:', len(file_name_with_path))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。