+ 13

Playground. How to move a file between two, different 🐍 python codes⁉️🤔 [impossible 😕]

I create & close a file in one code & I would like to open & read the same file in another code? Is it possible in SL Playground & how to do this? Both codes are in 🐍 python‼️ CODE1️⃣ CODE2️⃣ f=open('temp_f', 'w') f=open('temp_f', 'r') f.write('something') print(f.read()) f.close() f.close()

25th Feb 2022, 9:07 PM
Janusz Bujak 🇵🇱
Janusz Bujak 🇵🇱 - avatar
16 Réponses
+ 2
No, you should open the file in the same code not in a nother code because this is not allowed in sololearn
25th Feb 2022, 9:22 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 6
Every time you start a program on the playground, you start it on a random host. It doesn't know where your made your file previously. It only knows the program you are running now.
25th Feb 2022, 9:49 PM
Paul
Paul - avatar
+ 5
Muhammad Thanks, I was afraid of that, but I think you are talking about the same code, not the same playground⁉️🤔 For me, it's the worst answer witch I have to mark as the best‼️😕
25th Feb 2022, 9:32 PM
Janusz Bujak 🇵🇱
Janusz Bujak 🇵🇱 - avatar
+ 5
ChaoticDawg Thx, perhaps a cloud-based solution is possible, but I was thinking about storing the temporary file in the local directory of my computer⁉️🤔
26th Feb 2022, 7:40 AM
Janusz Bujak 🇵🇱
Janusz Bujak 🇵🇱 - avatar
+ 5
BroFar Thank you, but I would like to send one, temporary file between two different programs⁉️🤔 Write a second code "using db" that uses the same database created by your first code "creating db"‼️😶
26th Feb 2022, 8:05 AM
Janusz Bujak 🇵🇱
Janusz Bujak 🇵🇱 - avatar
+ 4
Janusz Bujak 🇵🇱 You can't store the file locally to use in 2 seperate programs here on SL (at least within the terms and conditionsof SL), but you can do so using your personal cloud storage. However, this is most likely a bit complicated, and the permission procedure may slightly vary from one cloud host to another. So, you'll have to research for yourself how to accomplish this if it is something you want to pursue further.
26th Feb 2022, 1:11 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Paul It's obvious, but tell me how to put the file in the Internet or store it locally on my own computer from SL Playground⁉️🤔
26th Feb 2022, 7:25 AM
Janusz Bujak 🇵🇱
Janusz Bujak 🇵🇱 - avatar
+ 4
Janusz Bujak 🇵🇱 I just did a quick dig though I mentioned it above .. cited: "Single-dbs have the advantage of letting application share enterprise data. Exactly as global data is shared by different modules." reference: https://softwareengineering.stackexchange.com/questions/378386/one-database-for-multiple-applications
26th Feb 2022, 8:43 AM
BroFar
BroFar - avatar
+ 4
It is not possible here.
27th Feb 2022, 4:19 PM
Abu Habban
Abu Habban - avatar
+ 2
Janusz Bujak 🇵🇱 you should be able to connect back to the database and / or utilize the csv between multiple codes / mini-programs.
26th Feb 2022, 8:27 AM
BroFar
BroFar - avatar
+ 2
Janusz Bujak 🇵🇱 It seems like you want to share data between two programs? If then you can use json hosts like https://jsonblob.com/api for that. Working example 👇 https://code.sololearn.com/crrsMjBY63dX/?ref=app
26th Feb 2022, 11:14 AM
OR!ON 🛡️
OR!ON 🛡️ - avatar
+ 1
Yes you can get your data from the internet, this is a sample that works for python: import urllib.request as req import pandas as pd import numpy as np result = req.urlopen('https://people.math.sc.edu/Burkardt/datasets/presidents/president_heights.csv') data=pd.read_csv(result) data.sort_values(by=['Name'], inplace=True, ascending=True) print(data)
26th Feb 2022, 7:00 AM
Paul
Paul - avatar
+ 1
Janusz Bujak 🇵🇱 I believe you are talking about something like this. I made this like 4 months ago as an example. https://code.sololearn.com/c0qLqnGRFhhU/?ref=app
26th Feb 2022, 7:25 AM
BroFar
BroFar - avatar
+ 1
I think he wants to do it with two sololearn programs, running seperately.
26th Feb 2022, 11:54 AM
Paul
Paul - avatar
0
Janusz Bujak 🇵🇱 if you noticed I created a database then created a csv file and at the bottom opened and used the csv file
26th Feb 2022, 7:33 AM
BroFar
BroFar - avatar
0
Nobody can do this here
27th Feb 2022, 5:27 PM
Abdul Ghaffar
Abdul Ghaffar - avatar