1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import
java.io
from datetime
import
datetime
from org.apache.commons.io
import
IOUtils
from java.nio.charset
import
StandardCharsets
from org.apache.nifi.processor.io
import
StreamCallback
class
GetDate(StreamCallback):
def __init__(self):
pass
def process(self, inputStream, outputStream):
#text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
dt =
''
months = [
1
,
4
,
7
,
10
]
for
year in range(
1990
,
2016
):
for
i in range(len(months)):
dt1 = datetime(year, months[i],
1
,
0
,
0
,
0
)
if
months[i] ==
10
:
dt2 = datetime(year+
1
,
1
,
1
,
0
,
0
,
0
)
else
:
dt2 = datetime(year, months[i]+
3
,
1
,
0
,
0
,
0
)
dt += dt1.strftime(
"%Y-%m-%d %H:%M:%S"
) +
','
+ dt2.strftime(
"%Y-%m-%d %H:%M:%S"
) +
";"
outputStream.write(dt)
flowFile = session.create()
if
(flowFile != None):
flowFile = session.write(flowFile, GetDate())
#flowFile = session.putAttribute(flowFile,
"filename"
, flowFile.getAttribute(
'filename'
).split(
'.'
)[
0
]+
'_translated.json'
)
session.transfer(flowFile, REL_SUCCESS)
session.commit()
|
本文转自疯吻IT博客园博客,原文链接:http://www.cnblogs.com/fengwenit/p/6170180.html,如需转载请自行联系原作者