Re: [Tutor] inserting path to open a file from a variable

2015-05-29 Thread Brandon McCaig
Richard: On Thu, May 28, 2015 at 1:39 PM, richard kappler wrote: > # line two is the absolute path to the log you are parsing data from > # keep 'rdfile:' as is, path starts after it, no spaces > rdfile:Documents/MyScripts/fileMonitor/log.txt > # line 4 is the absolute path to the log you are app

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Felix Dietrich
Mark Lawrence writes: > On 29/05/2015 01:16, Felix Dietrich wrote: > >> True, but the /optparse/ module does not appear to be part of Python >> 2.6. ("new in version 3.2") > > If you mean argparse you're correct, but it's in 2.7. My point is > that there's not much use writing code now with a de

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Felix Dietrich
richard kappler writes: > If I run my script to open a file in Documents/MyScripts/fileMonitor which > is where I'm doing my building and testing, with the variable rd1 (however > created, my way and ConfigParser way both work) from within > Documents/MyScripts/fileMonitor, the script fails with

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Mark Lawrence
On 29/05/2015 01:16, Felix Dietrich wrote: Mark Lawrence writes: optparse is deprecated, from https://docs.python.org/3/library/optparse.html "Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module".

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Felix Dietrich
Mark Lawrence writes: > optparse is deprecated, from > https://docs.python.org/3/library/optparse.html "Deprecated since > version 3.2: The optparse module is deprecated and will not be > developed further; development will continue with the argparse > module". argparse is here > https://docs.py

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Alan Gauld
CCing tutor list. ASlways use ReplyAll (or ReplyList ) to include the list. On 28/05/15 19:08, richard kappler wrote: What I've tried (none worked): file = open(rd1, 'r') This should have worked. What happened when you tried it? "Did not work" is a tad vague! Traceback (most recent

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Mark Lawrence
On 28/05/2015 20:01, Felix Dietrich wrote: richard kappler writes: Now I've been tasked to change the script so that the script doesn't need to be in the same directory as the log file, which makes perfect sense. Furthermore, the path can't be hard coded into the script, but rather should read

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread richard kappler
I found the problem, but the answer confuses me. If I run my script to open a file in Documents/MyScripts/fileMonitor which is where I'm doing my building and testing, with the variable rd1 (however created, my way and ConfigParser way both work) from within Documents/MyScripts/fileMonitor, the sc

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Felix Dietrich
richard kappler writes: > Now I've been tasked to change the script so that the script doesn't need > to be in the same directory as the log file, which makes perfect sense. > Furthermore, the path can't be hard coded into the script, but rather > should read the installer should be able to edit

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread richard kappler
Sorry Alan, I think I might have accidentally replied to only you. Love your Python Projects book btw! Working through it now. I've looked at, and played with a bit, ConfigParser and yes, it seems that may be a better idea, thank you. I still have the issue of how to get the path into my code, re

Re: [Tutor] inserting path to open a file from a variable

2015-05-28 Thread Alan Gauld
On 28/05/15 18:39, richard kappler wrote: I've created a config file which the user would edit named fileMonitor.conf: # line two is the absolute path to the log you are parsing data from # keep 'rdfile:' as is, path starts after it, no spaces rdfile:Documents/MyScripts/fileMonitor/log.txt # li

[Tutor] inserting path to open a file from a variable

2015-05-28 Thread richard kappler
This is a continuation of the read data script I asked for help on yesterday, which works very well thanks to all the help from the list. My script opens and reads in new lines from an in service log file, extracts specific data, writes it to another file for analysis. All of that works fine, test