fork download
  1. import csv
  2.  
  3. q = []
  4. with open('input.csv', 'r') as r:
  5. with open('output.csv', 'w') as w:
  6. cw = csv.writer(w)
  7. for n in r:
  8. n = n.strip()
  9. if n:
  10. n = int(n)
  11. if len(q)!=0 and n!=(int(q[-1])+1):
  12. cw.writerows(zip(map(str,q),[str(max(q))]*len(q)))
  13. q.clear()
  14. q.append(n)
  15. if q:
  16. cw.writerows(zip(map(str,q),[str(max(q))]*len(q)))
  17. q.clear()
  18. w.write('\n')
  19.  
Runtime error #stdin #stdout #stderr 0.15s 26092KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 4, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'input.csv'