당신은 변환을 수행하기 위해 GNU 날짜 유틸리티를 사용할 수 있습니다 :
date +"%m/%d/%Y %H:M:%S" -d "Mar 24 2014"
03/24/2014 00:00:00
문제는 당신이 사용할 수있는 도구를 지정하지 않지만,이 CSV 파일에 읽기 핸들 파이썬의 기본 솔루션입니다
, 날짜를 변환하고, 다른 CSV 파일로 출력 :
#!/usr/bin/python
import csv
from datetime import datetime
import sys
DATE_COLUMN = 3 # Or whatever column has the date
input_file = sys.argv[1]
output_file = sys.argv[2]
with open(input_file) as i_f:
reader = csv.reader(i_f)
with open(output_file, 'w') as o_f:
writer = csv.writer(o_f)
for row in reader:
date = datetime.strptime(row[DATE_COLUMN], "%h %d %Y")
row[DATE_COLUMN] = date.strftime("%m/%d/%Y %H:M:%S")
writer.writerow(row)
사용법 :
python csv_date_converter.py input_file output_file
하 ve는'date'를 사용하여 시도 했습니까? 맨 페이지를 읽으십시오. csv는 CSV입니까 아니면 공백으로 구분 된 입력란입니까? – Daenyth
날짜가 파일의 한 열 (예 : 3 열)에 나타나고 날짜를 변환 할 방법이 필요합니까? 사용할 수있는 도구에 제한이 있습니까? 예를 들어, Perl은 [Text :: CSV] (http://search.cpan.org/perldoc?Text%3A%3ACSV)를 사용하여 CSV 파일을 읽고 쓰고 [POSIX :: strptime] (http : // search .cpan.org/perldoc? POSIX % 3A % 3Astrptime) 및 [POSIX :: strftime] (http://perldoc.perl.org/POSIX.html#strftime)을 참조하십시오. Text :: CSV 및 POSIX :: strptime을 설치해야 할 수도 있습니다. –