python

Definition

python ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์‹คํ–‰ํ•˜๋Š” ๋…ธ๋“œ์ด๋‹ค. property ํŒจ๋„ "8.source"์— python ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. Source Editor ๋ฒ„ํŠผ("8.source" ์šฐ์ธก ๋ฒ„ํŠผ) ํด๋ฆญ ์‹œ Editor๊ฐ€ ํŒ์—…๋˜๋ฉฐ ๋ณด๋‹ค ํฐ ํ™”๋ฉด์—์„œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.
์ขŒ์ธก [Flow๊ตฌ์„ฑ]๋…ธ๋“œ ์ค‘ [python]๋…ธ๋“œ๋ฅผ drag & drop ํ•œ๋‹ค.

Set

[setting], [scheduler], [parameter] ์„ค์ •์€ [์›Œํฌํ”Œ๋กœ์šฐ ์ƒ์„ฑ] > [์„ค์ •]์„ ์ฐธ๊ณ ํ•œ๋‹ค.

property

[Node Description] ์ž‘์„ฑ ์ค‘์ธ ๋…ธ๋“œ๋ช… ์ž…๋ ฅ

property ์ค‘ 2~4 ํ•ญ๋ชฉ์€ [์—ฐ๊ฒฐ๊ด€๋ฆฌ]์— ๋“ฑ๋ก๋œ ์›๊ฒฉ์„œ๋ฒ„ ์ •๋ณด ์„ ํƒ์‹œ ์ž๋™์œผ๋กœ ์ž…๋ ฅ๋˜๋ฉฐ, ์›ํ•˜๋Š” ์„œ๋ฒ„๋ชฉ๋ก์ด ์—†์„ ๊ฒฝ์šฐ [์„ค์ •] > [์›๊ฒฉ์„œ๋ฒ„๊ด€๋ฆฌ]์—์„œ ํ•„์š”์„œ๋ฒ„๋ฅผ ๋จผ์ € ๋“ฑ๋กํ•œ๋‹ค.

  1. appName : appName ์ž…๋ ฅ
  2. python ์‹คํ–‰ IP : IP์ฃผ์†Œ ๋ฐ PORT
    • IP์ฃผ์†Œ : ์›๊ฒฉ์„œ๋ฒ„ ์ ‘์† IP
    • PORT : ์›๊ฒฉ์„œ๋ฒ„ ์ ‘์† PORT
  3. user : ์›๊ฒฉ ์„œ๋ฒ„ ์‚ฌ์šฉ์ž ์•„์ด๋””
  4. password : ์›๊ฒฉ ์„œ๋ฒ„ ์‚ฌ์šฉ์ž ํŒจ์Šค์›Œ๋“œ
  5. ์›๊ฒฉ์„œ๋ฒ„ ID : [์„ค์ •] > [์›๊ฒฉ์„œ๋ฒ„๊ด€๋ฆฌ]์— ์ €์žฅ๋œ ์„œ๋ฒ„ ID
  6. ์›๊ฒฉ์„œ๋ฒ„๋ช… : [์„ค์ •] > [์›๊ฒฉ์„œ๋ฒ„๊ด€๋ฆฌ]์— ์ €์žฅ๋œ ์„œ๋ฒ„๋ช…
  7. sourcepath : ๋ธŒ๋ผ์šฐ์ €๋ฅผ ํ†ตํ•ด ์›๊ฒฉ์„œ๋ฒ„์— ์ €์žฅ๋œ ์†Œ์Šค์„ ํƒ ํ›„ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ๊ธฐ๋Šฅ
  8. source : ์‹คํ–‰ํ•  python ์ฝ”๋“œ ์ž…๋ ฅ
  9. argument : ์ธ์ˆ˜ ์„ค์ •
  10. forceOK : ์‹คํŒจ ์‹œ ๊ฐ•์ œ OK ์ฒ˜๋ฆฌ ์—ฌ๋ถ€

Example

์›๊ฒฉ์„œ๋ฒ„์— ์ €์žฅ๋œ csv ํŒŒ์ผ์„ ์ฝ์–ด txt ํŒŒ์ผ๋กœ ์ƒ์„ฑํ•˜๋Š” ํŒŒ์ด์„  ์ฝ”๋“œ ์˜ˆ์ œ์ด๋‹ค. ์ˆ˜์ง‘์„œ๋ฒ„๋กœ ์ „๋‹ฌ๋˜๋Š” ์›์ฒœ๋ฐ์ดํ„ฐ๋ฅผ python์œผ๋กœ ์ „์ฒ˜๋ฆฌํ•˜๋Š” ์—…๋ฌด๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ ์ ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.

  1. hdfsToServer ๋…ธ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์›๊ฒฉ์ง€ ์„œ๋ฒ„๋กœ csvํŒŒ์ผ์„ ์˜ฎ๊ธด๋‹ค.
  • /home/dpcore/AIR_HOUR_2019_3.csv
  1. ์—ฐ๊ฒฐ๊ด€๋ฆฌ์—์„œ ์›๊ฒฉ์„œ๋ฒ„๋ฅผ ์„ ํƒํ•œ๋‹ค.

  2. 8.source ์˜ต์…˜์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ž…๋ ฅํ•œ๋‹ค.

import csv, sys
sys.stdout = open('output_air_hour2019.txt','w')
with open('/home/dpcore/AIR_HOUR_2019_3.csv','r') as file:
reader = csv.reader(file)
for record in reader:
print(record)

flow073

  1. ์ €์žฅ ๋ฐ ์‹คํ–‰ ํ›„ ์›๊ฒฉ์„œ๋ฒ„์— output_air_hour2019.txt ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜์—ˆ๋‹ค.

    flow074