sys.stdin = io.StringIO("workmen,hdfs://localhost:54310/hadoop_test/text_files/file1.txt 1\n workmen,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file1.txt 1\n workmen,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file2.txt 1\n workmen,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file4.txt 1\n workmen,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file5.txt 1\n workno,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file3.txt 1\n works,hdfs://localhost:54310/hadoop_test/text_files/file1.txt 33\n works,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file1.txt 33\n works,hdfs://localhost:54310/hadoop_test/text_files/lab_exercise6_file2.txt 34")
for each_line in sys.stdin:
each_line = each_line.strip()
value,total_num_words = each_line.split('\t',1)
print(value) #not returning anything the code just runs without error.
I have a string of text which i defined in sys.stdin. I would like to read each line and extract the word (e.g. workmen) the filename (e.g.- hdfs://localhost:54310/hadoop_test/text_files/file1.txt) and the count (e.g. 1 for the first case) however when i want to debug and print the value it does not return anything on jupyter. I guess its a variable scope issue or the loop is not running to return the output for 'value'. Is there any workaround to this?
sys.stdinany specific reason ?