简体   繁体   English

数据分析-Python

[英]Data analysis - Python

Basically I am bored and making a program which can encode and decode data in txt files.基本上我很无聊,正在制作一个可以对 txt 文件中的数据进行编码和解码的程序。

Given a partially randomly generated text which has several ways of representing dates, eg: '9 DECEMBER 19', '19 december 9', '19/9/12', '9 December 19', '12.9,19'... you get the idea.给定一个部分随机生成的文本,它有多种表示日期的方式,例如:'9 DECEMBER 19'、'19 december 9'、'19/9/12'、'9 December 19'、'12.9,19'...你明白了。 How would you convert all the dates present in the txt file to an ISO format (eg 2021-12-23).您如何将 txt 文件中的所有日期转换为 ISO 格式(例如 2021-12-23)。 The execution of the code has to be relatively efficient given I could deal with a txt file of +25 000 lines.鉴于我可以处理 +25 000 行的 txt 文件,代码的执行必须相对高效。

Thanks in advance:)提前致谢:)

You can use dateutil -您可以使用dateutil -

from dateutil import parser
parser.parse(line)
#inside a loop

Source - https://stackoverflow.com/a/470303/17524070来源-https://stackoverflow.com/a/470303/17524070

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM