{"id":2450,"date":"2013-05-22T14:41:27","date_gmt":"2013-05-22T05:41:27","guid":{"rendered":"http:\/\/apollo89.com\/wordpress\/?p=2450"},"modified":"2013-05-22T14:46:23","modified_gmt":"2013-05-22T05:46:23","slug":"python%ed%8c%8c%ec%9d%bc%ed%8f%ac%eb%a9%a7-%eb%b3%80%ed%99%98","status":"publish","type":"post","link":"https:\/\/apollo89.com\/wordpress\/?p=2450","title":{"rendered":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658"},"content":{"rendered":"<p>&nbsp;<br \/>\n\uac04\ub2e8\ud55c \ud30c\uc77c \ubcc0\ud658 \ud504\ub85c\uadf8\ub7a8 \uac1c\ubc1c..<\/p>\n<p>\uc544\ub798\uacfc \uac19\uc740 \uc0d8\ud50c\ud30c\uc77c\uc744 \ubc1b\uc544\uc11c <\/p>\n<pre class=\"lang:default decode:true \" >[COL1]: 2013-04-17 11:42:32\r\n[COL2]: \r\n[COL3]: \r\n\r\n[COL1]: 2013-04-17 11:42:34\r\n[COL2]: aaaa\r\n[COL3]: bbbb<\/pre>\n<p>\uc544\ub798\uc758 \ud3ec\ub9f7\uc73c\ub85c \ubcc0\uacbd<\/p>\n<pre class=\"lang:default decode:true \" >filename\u26062013-04-17 11:42:32\u2606\u2606\r\nfilename\u26062013-04-17 11:42:34\u2606aaaa\u2606bbbb<\/pre>\n<p>\uc791\uc131\ud55c \uc18c\uc2a4\ucf54\ub4dc<\/p>\n<pre class=\"lang:default decode:true \" >\r\n# filename : format_trans.py\r\n# -*- coding: utf-8 -*-\r\nimport optparse\r\n\r\ndef csvTrans(filename):\r\n\tf = file(filename, 'r')\r\n\tfw = open(\"res_\"+filename, \"w\")\r\n\tlinecount = 0\r\n\tres = dict()\r\n\t\r\n\twhile True:\r\n\t\tline = f.readline()\r\n\r\n\t\tif not line  :\r\n\t\t\tif res.values() :\r\n\t\t\t\tfw.write(filename+\"\u2606\"+res[\"COL1\"]+\"\u2606\"+res[\"COL2\"]+\"\u2606\"+res[\"COL3\"]+\"\\n\")\r\n\t\t\t\tprint(filename+\"\u2606\"+res[\"COL1\"]+\"\u2606\"+res[\"COL2\"]+\"\u2606\"+res[\"COL3\"])\r\n\t\t\tbreak\r\n\t\telif line == \"\\n\" :\r\n\t\t\tfw.write(filename+\"\u2606\"+res[\"COL1\"]+\"\u2606\"+res[\"COL2\"]+\"\u2606\"+res[\"COL3\"]+\"\\n\")\r\n\t\t\tprint(filename+\"\u2606\"+res[\"COL1\"]+\"\u2606\"+res[\"COL2\"]+\"\u2606\"+res[\"COL3\"])\r\n\t\t\tres = dict()\r\n\t\telse :\r\n\t\t\tparsed_list = line.rstrip('\\n').split(']: ')\r\n\r\n\t\t\tif parsed_list[0].find(\"COL1\") > 0 :\r\n\t\t\t\tres[\"COL1\"] = parsed_list[1]\r\n\t\t\tif parsed_list[0].find(\"COL2\") > 0 :\r\n\t\t\t\tres[\"COL2\"] = parsed_list[1]\r\n\t\t\tif parsed_list[0].find(\"COL3\") > 0 :\r\n\t\t\t\tres[\"COL3\"] = parsed_list[1]\r\n\r\n\tf.close()\r\n\tfw.close()\r\n\r\n\r\ndef main():\r\n\tparser = optparse.OptionParser('usage format_trans.py -f filename')\r\n\tparser.add_option('-f', dest='filename', type='string', help='input file')\r\n\r\n\t(options, args) = parser.parse_args()\r\n\r\n\tfilename = options.filename\r\n\r\n\tif filename == None :\r\n\t\tprint parser.usage\r\n\t\texit(0)\r\n\r\n\tcsvTrans(filename)\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n<\/pre>\n<p>\uc544\ub798\uc640 \uac19\uc774 \uc2e4\ud589\ud558\uba74 \ub41c\ub2e4.<\/p>\n<pre class=\"lang:default decode:true \" >C:\\Python27\\apollo89_study&gt;python format_trans.py -f sample.txt\r\nsample.txt\u26062013-04-17 11:42:32\u2606\u2606\r\nsample.txt\u26062013-04-17 11:42:34\u2606aaaa\u2606bbbb<\/pre>\n<p>\uacb0\uacfc \ud30c\uc77c\uc740 res_sample.txt \uc5d0 \uc800\uc7a5<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \uac04\ub2e8\ud55c \ud30c\uc77c \ubcc0\ud658 \ud504\ub85c\uadf8\ub7a8 \uac1c\ubc1c.. \uc544\ub798\uacfc \uac19\uc740 \uc0d8\ud50c\ud30c\uc77c\uc744 \ubc1b\uc544\uc11c [COL1]: 2013-04-17 11:42:32 [COL2]: [COL3]: [COL1]: 2013-04-17 11:42:34 [COL2]: aaaa [COL3]: bbbb \uc544\ub798\uc758 \ud3ec\ub9f7\uc73c\ub85c \ubcc0\uacbd filename\u26062013-04-17 11:42:32\u2606\u2606 filename\u26062013-04-17 11:42:34\u2606aaaa\u2606bbbb \uc791\uc131\ud55c \uc18c\uc2a4\ucf54\ub4dc # filename : format_trans.py # -*- coding: utf-8 -*- &hellip; <a href=\"https:\/\/apollo89.com\/wordpress\/?p=2450\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[663],"tags":[140],"class_list":["post-2450","post","type-post","status-publish","format-standard","hentry","category-python-","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/apollo89.com\/wordpress\/?p=2450\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com\" \/>\n<meta property=\"og:description\" content=\"&nbsp; \uac04\ub2e8\ud55c \ud30c\uc77c \ubcc0\ud658 \ud504\ub85c\uadf8\ub7a8 \uac1c\ubc1c.. \uc544\ub798\uacfc \uac19\uc740 \uc0d8\ud50c\ud30c\uc77c\uc744 \ubc1b\uc544\uc11c [COL1]: 2013-04-17 11:42:32 [COL2]: [COL3]: [COL1]: 2013-04-17 11:42:34 [COL2]: aaaa [COL3]: bbbb \uc544\ub798\uc758 \ud3ec\ub9f7\uc73c\ub85c \ubcc0\uacbd filename\u26062013-04-17 11:42:32\u2606\u2606 filename\u26062013-04-17 11:42:34\u2606aaaa\u2606bbbb \uc791\uc131\ud55c \uc18c\uc2a4\ucf54\ub4dc # filename : format_trans.py # -*- coding: utf-8 -*- &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/apollo89.com\/wordpress\/?p=2450\" \/>\n<meta property=\"og:site_name\" content=\"Apollo89.com\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-22T05:41:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-05-22T05:46:23+00:00\" \/>\n<meta name=\"author\" content=\"apollo89\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"apollo89\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450\"},\"author\":{\"name\":\"apollo89\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\"},\"headline\":\"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658\",\"datePublished\":\"2013-05-22T05:41:27+00:00\",\"dateModified\":\"2013-05-22T05:46:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450\"},\"wordCount\":6,\"commentCount\":0,\"keywords\":[\"\ud30c\uc774\uc36c\"],\"articleSection\":[\"Python\\\/Ruby\\\/Perl\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450\",\"name\":\"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#website\"},\"datePublished\":\"2013-05-22T05:41:27+00:00\",\"dateModified\":\"2013-05-22T05:46:23+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=2450#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\\\/\\\/apollo89.com\\\/wordpress\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#website\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/\",\"name\":\"Apollo89.com\",\"description\":\"\uc544\ud3f4\ub85c\uc528\uc758 \uc7a1\ub2e4\ud55c \uacbd\ud5d8\ub4e4..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\",\"name\":\"apollo89\",\"description\":\"\uc544\ud3f4\ub85c89 \uc785\ub2c8\ub2e4.\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/apollo89.com\/wordpress\/?p=2450","og_locale":"ko_KR","og_type":"article","og_title":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com","og_description":"&nbsp; \uac04\ub2e8\ud55c \ud30c\uc77c \ubcc0\ud658 \ud504\ub85c\uadf8\ub7a8 \uac1c\ubc1c.. \uc544\ub798\uacfc \uac19\uc740 \uc0d8\ud50c\ud30c\uc77c\uc744 \ubc1b\uc544\uc11c [COL1]: 2013-04-17 11:42:32 [COL2]: [COL3]: [COL1]: 2013-04-17 11:42:34 [COL2]: aaaa [COL3]: bbbb \uc544\ub798\uc758 \ud3ec\ub9f7\uc73c\ub85c \ubcc0\uacbd filename\u26062013-04-17 11:42:32\u2606\u2606 filename\u26062013-04-17 11:42:34\u2606aaaa\u2606bbbb \uc791\uc131\ud55c \uc18c\uc2a4\ucf54\ub4dc # filename : format_trans.py # -*- coding: utf-8 -*- &hellip; Continue reading &rarr;","og_url":"https:\/\/apollo89.com\/wordpress\/?p=2450","og_site_name":"Apollo89.com","article_published_time":"2013-05-22T05:41:27+00:00","article_modified_time":"2013-05-22T05:46:23+00:00","author":"apollo89","twitter_card":"summary_large_image","twitter_misc":{"\uae00\uc4f4\uc774":"apollo89","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"1\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/apollo89.com\/wordpress\/?p=2450#article","isPartOf":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=2450"},"author":{"name":"apollo89","@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82"},"headline":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658","datePublished":"2013-05-22T05:41:27+00:00","dateModified":"2013-05-22T05:46:23+00:00","mainEntityOfPage":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=2450"},"wordCount":6,"commentCount":0,"keywords":["\ud30c\uc774\uc36c"],"articleSection":["Python\/Ruby\/Perl"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/apollo89.com\/wordpress\/?p=2450#respond"]}]},{"@type":"WebPage","@id":"https:\/\/apollo89.com\/wordpress\/?p=2450","url":"https:\/\/apollo89.com\/wordpress\/?p=2450","name":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658 - Apollo89.com","isPartOf":{"@id":"https:\/\/apollo89.com\/wordpress\/#website"},"datePublished":"2013-05-22T05:41:27+00:00","dateModified":"2013-05-22T05:46:23+00:00","author":{"@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82"},"breadcrumb":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=2450#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/apollo89.com\/wordpress\/?p=2450"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/apollo89.com\/wordpress\/?p=2450#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/apollo89.com\/wordpress"},{"@type":"ListItem","position":2,"name":"[python]\ud30c\uc77c\ud3ec\uba67 \ubcc0\ud658"}]},{"@type":"WebSite","@id":"https:\/\/apollo89.com\/wordpress\/#website","url":"https:\/\/apollo89.com\/wordpress\/","name":"Apollo89.com","description":"\uc544\ud3f4\ub85c\uc528\uc758 \uc7a1\ub2e4\ud55c \uacbd\ud5d8\ub4e4..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/apollo89.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Person","@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82","name":"apollo89","description":"\uc544\ud3f4\ub85c89 \uc785\ub2c8\ub2e4.","url":"https:\/\/apollo89.com\/wordpress\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2450"}],"version-history":[{"count":0,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2450\/revisions"}],"wp:attachment":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}