QGIS Overwrite CSV By mike on 28th March 2021 03:43:00 PM
  1. #Read last line from large log files by bits and
  2. #savie it to a single line CSV to be monitored in QGIS
  3. #SeaIT - rev 190224a
  6. # required
  7. import os
  9. #The file to read from - use a small one to test in case it shits itself
  10. #readfile = "Z:/10030530 Borssele III&IV_SBP/21 NHP/21 Survey Online/01 [100XXXXX - Online Project]/LogFiles/Output to QGIS - Logfile 24Feb19.txt"
  11. readfile = "Z:/10030530 Borssele III&IV_SBP/21 NHP/21 Survey Online/01 [100XXXXX - Online Project]/LogFiles/BLACKBOX Borssele III IV SBP.txt"
  13. #Your CSV to write to - will be created if non existing
  14. writefile = "Z:/10030530 Borssele III&IV_SBP/21 NHP/29 Reporting/20 Ops QGIS/Ops QGIS Layers/07 SBP Phase/vessel.csv"
  16. #Do the magic
  17. with open(readfile, 'rb') as fr:
  18., os.SEEK_END)
  19.   while != b'\n':
  20., os.SEEK_CUR)
  21.   with open(writefile, 'w+') as fw:
  22.     fw.writelines(fr.readline().decode())

Hasta la pasta! is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.