【发布时间】:2021-07-28 04:28:08
【问题描述】:
log_input.log
1949,1603441909,984159,0.002608,19.8829994202,0.0,640.0
950,1603441910, 416274
21,160340, 24666082,0.002608,19.81913,0.0,638.0
检查列的一致性,如果列号不一致则忽略该行。读取第二列,将第二列转换为本地时间格式。
log_output.log
1949, 10-31-49,984159,0.002608,19.8829994202,0.0,640.0
21, 9-32-20, 24666082,0.002608,19.81913,0.0,638.0
代码:
with open('log_input.txt', 'r') as f:
csv_data = csv.reader(f)
csv_lines = list(csv_data)
for line in csv_lines:
line[1] = convert(line[1].split(':')[1].strip())
【问题讨论】:
-
欢迎来到 Stack Overflow!请拨打tour,阅读what's on-topic here、How to Ask和question checklist,并提供minimal reproducible example。 “为我实现此功能”与此站点无关。你必须诚实地尝试,然后就你的算法或技术提出一个具体问题。 How much research effort is expected of Stack Overflow users?
-
自纪元以来的秒数->“可读日期”基本上在Converting unix timestamp string to readable date中描述