Re: Help with VBA for document formatting.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance






Hello, Rob.

I just tried your Python routine but got an error message stating the
following:

/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python: can't open file 'processtext.py':
[Errno 2] No such file or directory

At first I thought it had something to do with the fact that it might
be looking for the file 'processtext.py' in the main directory while I
had it on my desktop. So I transferred the files to the main directory
but nothing changed - the result was the same error message.

Is there something I am missing ?

Thank you,

Joe

Joe,

It means that you launched Python and asked it to load the 'processtext.py' file and it can't find it. Probably because when you launched Python the file processtext.py and the input file was not in the current directory. It has to be in the 'current directory' simply because you did not give a full path to the actual file location. The computer has to be told what to do. It cannot read the user's mind.

I don't know what you mean by "main directory".

'processtext.py' is the name I suggested you give to the little programme file. Is this the file name you gave it?

The error message suggests that it can't find the file; so on that that basis let's go through the steps to take. I will be *very* explicit. While there are a lot of words here, it is simple.

1. Launch the Mac program "TextEdit" using Finder and from the Applications Folder.

2. Copy/paste the program I provided previously into TextEdit. Edit the name of the input file name and output file name you will use. I suggest "input.txt" and "output.txt". Use whatever you like. Ensure that the indented portions of the program are, as mentioned previously, all four spaces (or if not four then must all be the same, e.g. three). Do not use tabs, do not use inconsistent indents.

3. Save the file into the "Documents" folder as 'processtext.py'. (You can put it in any folder you like, including Desktop ... I just say Documents just so that I can write this procedure and pick an existing folder to avoid creating a new folder which adds more steps to the procedure).

4. Copy the file which holds your text that you wish to transform into the "Documents" folder. Use Finder.

5. Open the Mac "Terminal" program. You'll probably find it on the "Dock" but not there, launch it via Finder in the Applications/Utilities folder (help at Google "launch mac terminal")

6. Unless you changed something, the Mac will put you into terminal mode in the /Users/[youruserid] folder. Change to the Documents folder by issuing the command (without the quote marks), "cd Documents" then press Return Key.

7.The "current directory" will be /Users/[youruserid/Documents". Check this by issuing the command "pwd" to see the *p*present *w*working *d*iretory.

8.Confirm that your "processtext.py is there by issuing the command "ls
passwordtext.py" and if it is the Mac will respond by by showing you the file name. If the file is not present, go back to steps 1, 2, and 3. This file must be in this folder simply because we keep it simple by not putting it elsewhere which would require giving a full path name when launching the program.

9.Confirm that your input file (called "input.txt"???) is in that folder by issuing the "ls input.txt" file. If it is not there, then go to step 4 above. This file must be in this folder simply because we keep it simple by not putting it elsewhere which would require giving a full path name in the programm.

10. Issue the command "python processtext.py" which will a. launch Python, b. load the "processtext.py" file from the current directory (Documents), then run that program. It should create the file output.text (or whatever you called it in step 2 above) into the current folder (Documents). It should only take a few seconds (depending on the size of the input file).

11. With Word or TextEdit, look at the output.txt file and see if it did what you wanted.

12. If it did not, then you need to adjust the Python program to do what you actually want if you want to use Python. You may also find that the input data format/pattern is not exactly as expected and therefore the program may not work. You can then chose to change the data format/pattern, or make the program more sophisticated to enable transforming the unexpected format/patter. That's just life when munging data.


--rms

www.rmschneider.com


.



Relevant Pages

  • Re: Help with VBA for document formatting.
    ... It means that you launched Python and asked it to load the ... Applications Folder. ... launch it via Finder in the Applications/Utilities ... ....will put 1 tab stops in Body Regions;A01 ...
    (microsoft.public.mac.office.word)
  • Re: Help with VBA for document formatting.
    ... It means that you launched Python and asked it to load the ... Applications Folder. ... the name of the input file name and output file name you will use. ... launch it via Finder in the Applications/Utilities ...
    (microsoft.public.mac.office.word)
  • Re: Help with VBA for document formatting.
    ... It means that you launched Python and asked it to load the ... Applications Folder. ... the name of the input file name and output file name you will use. ... launch it via Finder in the Applications/Utilities ...
    (microsoft.public.mac.office.word)
  • Re: Can two accounts use the same Applications word excel powerpoint etc
    ... A User is a term used by the Mac OS. ... The Users folder resides at the root level of the ... Do other non Apple applications launch in this User? ... Entourage Help Page ...
    (microsoft.public.mac.office)
  • Re: Python packages on the Mac
    ... I would like to copy the contents of the PythonFramework.pkg folder ... and run python without having to run the installer on the Mac. ... How can this be done on the Mac? ... "man pax" can tell you more about the pax command, pkg bundles, and the like. ...
    (comp.lang.python)