GOAL
I have a text file which receives receives at least 20 more lines every seconds. What I want is that every time a new line appears in my txt file, I want the line to go through a process. For example, the line will be uppercase and print it out. And then wait for the next line to appear.
WHAT I TRIED
My idea was to read the file like we can normally read a file line by line in python because by the time it was reading the lines, some more lines would be added. However, python reads the lines too fast... This was my code:
file = open('/file/path/text.txt')
for line in file:
line = line.upper
print(line)
time.sleep(1)
I know there is PySpark, but is there an easier solution? Because I only have one text file and it must go through a simple process (eg: upper case read lines, print line and then wait for next line to appear).
I am a newbie in python so I am sorry if the answer is obvious for some of you. I would appreciate any help. Thank you.