Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello β I'm @olemoritz on Twitter.
File handling CSV files and TXT files within Phytonista
-
Hallo. I'm new to this forum and to the use of Phytonista. I live in Holland and my English is probably not the best there is. But nevertheless I want to ask a question and I hope that you can help me.
On my laptop I use python scripts to read and write to and from CSV files and TXT files. All my files are in the iCloud folder. I noticed that I can easily acces those files using Phytonista, but running my py scripts with Phytonista gives the following error:
[Errno 1] Operation is not permitted: 'nummer.csv'
Does this mean, that I cannot use my CSV files that are stored within iCloud?
Is there a way to solve this Problem? -
@jokiehints could you give the line which gave the error?
-
The traceback call was:
Traceback (most recent call last):
File "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/python_files/num_files/testing.py", line 6, in <module>
with open(filename, newline = '') as file_object:
PermissionError: [Errno 1] Operation not permitted: 'nummer.csv'Is this helpfull?
-
The same code runs without problems on my laptop. Should I make changes in my code?
-
@jokiehints could you post the begin of your script to see from where comes filename
-
The code is as follows:
import csv
filename = 'nummer.csv'
with open(filename, newline = '') as file_object:
csvreader = csv.reader(file_object, delimiter = ';', dialect='excel',)
csv_headings = next(csvreader)
first_line = next(csvreader)
vnaam = int(first_line[0])
anaam = int(first_line[1])
dnaam_1 = int(first_line[2])
dnaam_2 = int(first_line[3])
dnaam_3 = int(first_line[4])
geb_dag = int(first_line[5])
geb_mnd = int(first_line[6])
geb_jr = int(first_line[7]) -
@jokiehints Sorry, but I don't understand, you say that your .csv file is in iCloud and you open it in the same folder as your script...
-
I believe this problem has been discussed before.. you cannot really read/write from the iCloud folder directly -- iirc. You must copy the files out to a This Ipad folder-- then copy back updated files
-
@cvp**:** Many thanks for your concern. I'm very gratefull!
Both files are in Icloud and in the same folder.
When I run the code on my laptop there is no probleem. I get the results I want. But when I run the code in Pythonista, I get the error code and the traceback.
I'm using python 3.7.2. Maybe that's the problem?
Other question: Schould the csv file normally be accessible to read en write when using Pythonista?
Is that the same with TXT files? I have several scripts were I exchange data to other files.
I hope that this is also possible when using Pythonista. I hope you can discover the problem. -
@JonB: Thank you for your response. I thought of this before, but my first question is how do I get these files on my ipad in the right place.
Second: In your answer you specified "This Ipad Folder" Is that the actual name or did you meant another folder?
I'm sorry if my english is not good. But I hope you understand my questions. -
@jokiehints Could you try to create a folder num_files under the Pythonista3 folder of iCloud Drive and to copy your .py and csv... files there, it should work, I think
Edit: I've tested with a little script that updates a file on iCloud and it is ok
with open('test.txt',mode='at') as fil: fil.write('xxxxyyy\n')
-
@jokiehints the num_files folder in iCloud Drive folder of Pythonista3 will be accessible in the Pythonista browser
-
@cvp: Yes!! Thank you very much. That's is the solution. This works wonderfull. All my python work is now useble within Pythonista!
-
@jokiehints πΎπ