From 03e426dc8209dae68e82f57871daab38b2a2d0e4 Mon Sep 17 00:00:00 2001 From: vinod-boga Date: Sat, 9 Sep 2017 16:35:44 +0000 Subject: [PATCH 1/2] Done --- count_word.py | 15 +++++++++++++++ count_word.pyc | Bin 0 -> 621 bytes tests/__init__.pyc | Bin 0 -> 151 bytes tests/test_countWord.pyc | Bin 0 -> 1195 bytes 4 files changed, 15 insertions(+) create mode 100644 count_word.pyc create mode 100644 tests/__init__.pyc create mode 100644 tests/test_countWord.pyc diff --git a/count_word.py b/count_word.py index e69de29..7f92a98 100644 --- a/count_word.py +++ b/count_word.py @@ -0,0 +1,15 @@ +def countWord(filepath,word): + lines = open(filepath,'r') + counter = 0 + + for line in lines: + words = line.split() + for i in words: + if (word == i): + counter += 1 + else: + counter += 0 + + return counter + +print countWord('/home/vinod-boga/Workspace/code/005-count-word/files/testfile.txt','dummy') diff --git a/count_word.pyc b/count_word.pyc new file mode 100644 index 0000000000000000000000000000000000000000..458384a985fe6e5d246707d483116dd17b0167ed GIT binary patch literal 621 zcmb_ZO;5r=5PiD^1R|PnGSMGU4^TW14-%u%s3#6;LNqZ3yQ>sRw{#bUq&?wJ@}Kz! zoLwcJO>8o+^YLchOzV9%>PI^tcOiZrkKQL_dY3=|@4!7E$!8E8D~`)6;o-(FQ9a}Y z8)P;(BhzC71LTfRrQRQkj@CIXaCacG%d p)@z%EahHhsbh_;OR_wY?@O#cb-BhKay{QuOSRT8R>>sIZeF2Q0iIM;S literal 0 HcmV?d00001 diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85422961cb67432fc9434a8a65aff6af1ec7fc57 GIT binary patch literal 151 zcmZSn%**v}%DTv81}I1X8Urs|hv=H;j8 zCgrCm>WAkSWfvDDCa3Br=clCV8yJ}CCg+#tmFSk|7p3Tzq!yPH>&M4u=4F<|$LkeT WmT&+KvB}L(Da}c>16frJ#0&u8{vx9Q literal 0 HcmV?d00001 diff --git a/tests/test_countWord.pyc b/tests/test_countWord.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c3313fb8688a031f83a31d219327e6e5108d5be7 GIT binary patch literal 1195 zcmcIj!EVz)5S_J?G%YFwfk3J_^yo|La^O-S1XNT)LOnQ@N+Ti5*c&jlcY}8gL~2jv z#+AQ7;y?Hv?!cQdY4QOOc_%xw&$I8%jKiOs8^6AOKh5dyFU0?2EO!V~;89c&)ruyH z6#D^H0o5T*LaKW-=~3OMNgrn+X+={-MUOrcT@sy622}KE91W1F{Ec6vu=7KhW9|Gw z=5)mO`I|7trqkBszO*Kt+SU|)glK7U+cY}&scrqN^?nUO*XFs_h2O+p5&`Z{Y*SpR z;Cr4jk~3>!^570ylYo-3(8w9n!|G!lV7VVKbIpobq=>$N=yUiXtGW#6BA|1kcLD1< z4>+{UHavXNYfQRIJRIJgZ;zymBSJd-;I@_S;3n`^I<$xefC5jh^i{wVpOGq6@>rivFQg!z8MWNhnc)Rhmth9?gdcnJ0|H*?Edfe9aybQ1t z_l0eAo$!IX4#UuGWBs;tDcWEd8%dsiL>mO_uOXH>ryKw5eVbK+>HOoS)rmBoG0*Fn z1*U0Wm+u^AmD7pL3t##~5@9w3moT@8n}@=JmaeAVojhrcc5T%SO1HfqAxdIos^hn| z*71kZ*kb3keUrr)oijJfavkTk(DB~hgB=mG!(ya7U6InO`t8od03CK>)8L80=ntHvX4zhlNDbuat_Y90$a literal 0 HcmV?d00001 From e69944b4ec82151bc164ffb759fe4b398407d590 Mon Sep 17 00:00:00 2001 From: vinod-boga Date: Sat, 9 Sep 2017 17:45:34 +0000 Subject: [PATCH 2/2] Done --- count_word.py | 2 +- count_word.pyc | Bin 621 -> 621 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/count_word.py b/count_word.py index 7f92a98..f2ee4c0 100644 --- a/count_word.py +++ b/count_word.py @@ -1,5 +1,5 @@ def countWord(filepath,word): - lines = open(filepath,'r') + lines = open(filepath,'r') # open file to read counter = 0 for line in lines: diff --git a/count_word.pyc b/count_word.pyc index 458384a985fe6e5d246707d483116dd17b0167ed..e940dafb90c01f43552f7b48dd224d129c835e2c 100644 GIT binary patch delta 15 WcmaFM@|J~-`7