File not opening in program

Asked by Tyler

I am trying to open a file from a directory, edit the file, then move on to the next file. I can open the program, but the file never opens up in it. Here is my code thus far:

openApp("C:\\Program Files (x86)\\Nuance\\Power PDF\\bin\\NuancePDF.exe")

import os
dir = "C:\\Users\\user\\Desktop\\PDF Testing\\test\\"
for e in os.listdir(dir): # this starts the loop
    fileName = os.path.join(dir, e)
    print fileName
    f = open(fileName)

 # edits of the file

    f.close

Any tips to get the file to open?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

Take a look at Python documentation in regards to how to open a file:
https://docs.python.org/2/library/functions.html#open

You must pass at least the 2 following values to "open":
1. name - file name to be opened
2. mode - string indicating how the file is to be opened

Follow the below link to choose a mode best suitable for your need.
http://www.manpagez.com/man/3/fopen/

Cheers,
Eugene

Can you help with this problem?

Provide an answer of your own, or ask Tyler for more information if necessary.

To post a message you must log in.