04-08-2020 08:06 AM
Hi guys,
I'm trying to append line to existing python file but I'm having issues finding the commands I need to do so.
I want my program to:
Open the python file, read it to text, search for the string 'enter sizes below' and then append my string in a new line.
Unfortunately, I couldn't find the right command that will allow me to set the file position right after the word 'below' and then append.
I'm attaching the python code as well.
Thanks!
04-08-2020 08:38 AM
You can't do that directly in the file (unless it ends with the searched for file), so what you need to do it:
Read all of the file as string
Search for your text and cut the string at this point to part 1 and part 2
Build a new string with Part 1 + your insert + part 2
Write this new string to file.
04-08-2020 08:40 AM - edited 04-08-2020 08:41 AM
Well, there it is... I never thought I'd see the day when text-based code would be presented as a picture... 😄