8.96. year 西暦年¶
書式1: year(date)
書式2: year(time)
書式3: years(date)
書式4: years(time)
日付 \(date\) もしくは時刻 \(time\) から西暦年を取り出す。 書式1,2は数値として返し、書式3,4は文字列として返す。
利用例¶
importと入力データ(CSV)の準備
1import nysol.mcmd as nm 2 3with open('dat1.csv','w') as f: 4 f.write( 5'''id,date 61,20000101 72,20121021 83, 94,19770812 10''') 11 12with open('dat2.csv','w') as f: 13 f.write( 14'''id,time 151,20000101000000 162,20121021111213 173, 184,19770812122212 19''')
基本例
1nm.mcal(c='year($d{date})', a='rsl', i="dat1.csv", o="rsl1.csv").run() 2### rsl1.csv の内容 3# id,date,rsl 4# 1,20000101,2000 5# 2,20121021,2012 6# 3,, 7# 4,19770812,1977
時刻型でも可能
1nm.mcal(c='year($t{time})', a='rsl', i="dat2.csv", o="rsl2.csv").run() 2### rsl2.csv の内容 3# id,time,rsl 4# 1,20000101000000,2000 5# 2,20121021111213,2012 6# 3,, 7# 4,19770812122212,1977