0

I am writing a csv file in one program. It will append the output file every 15 minutes. I want to read all the content of the output file till it stops writing. I want another program to wait for 30 minutes if no change in the output file then stop reading. Alternatively how to read it with csv package?

# File Writing
csvfile = open(output_file_name, 'a')
csvwriter = csv.writer(csvfile, delimiter=',', quotechar = '"')

# Some logic
csvwriter.writerow(data)
....

# finally close file
csvfile.close()

# File Reading
for df in pd.read_csv(output_file_name, chunksize=1000):
    # Some logic
    ...

Currently File can read upto what it has written to the output_file before start reading. Changes done to the output files are discarded while reading output_file file at the same time.

Hariprasad
  • 1,611
  • 2
  • 14
  • 19
  • possible duplicate https://stackoverflow.com/questions/28726717/reading-from-a-csv-file-while-it-is-being-written-to – Kryesec Jan 16 '19 at 08:43
  • Already I have read that question before asking this question. @Kryesec The question you marked as duplicate is not the answer I am looking for. I have mentioned I need a programmatic solution using pandas. I can say this question is a duplicate of https://stackoverflow.com/questions/7537054/reading-a-file-while-its-being-written. But it is answered in Java. – Hariprasad Jan 16 '19 at 10:50

0 Answers0