Replace words in txt file

18 posts / 0 new
Last post
JHDCC
Offline
Joined: 02/15/2017 - 11:28

Thanks klmi, that looks like it does exactly what I'm after and is easily understandable and I can adapt it for my purposes. However, I can't work out how I can save it or run it! 
I am hoping to save this as a script, which I can call/run from another script.
Thanks for any assistance.

klmi
Offline
Joined: 02/13/2019 - 08:41

Hi JHDCC,
 
you don't need to run it from another script but you can ;-)
1) Copy the code in notepad and save the file with extension .py within your IDEA makro library
2) check in your IDEA options whether to run Python programs is activated (IDEA 10.3 and above necessary)
3) run the program directly from the library

JHDCC
Offline
Joined: 02/15/2017 - 11:28

Thanks again Klmi,
Nearly there I think, but I get an indentation error on line 7, which i presume is a formatting issue?
Any ideas? That's python, SQL and VB I need to do some reading on now!

Images: 
klmi
Offline
Joined: 02/13/2019 - 08:41

Yes it's a formatting issue. The indentations in my code are destroyed (forum editor is a crap). But I'll  try to edit this. Otherwise you can make a TAB a the beginning of the lines containing f.read and f.write.

JHDCC
Offline
Joined: 02/15/2017 - 11:28

Thanks for all your help klmi. It didn't quite work as I'd hoped, so adapted the script to retain the encapsulation before removing the ".There's probably a more direct way of achieving this, but it worked.
I also had to change the server path to \\ instead of \ and add the tabs as klmi directed.
For the benefit of anyone picking this up in the future, please see attached script for reference.

klmi
Offline
Joined: 02/13/2019 - 08:41

Notice: for paths always use "/" (like in my code block) or "\\" in Python code

raoul.kelly
Offline
Joined: 08/13/2019 - 07:12

Thanks klmi ...that looks awesome!

Pages