Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Manager
2,167 Views

Writing files using the Intel Edison

Hello All,

I have a question as to where the Edison writes files that you create in the source code. I created a file on my python program, but I can't find where it was stored.

Thanks,

Melvin

10 Replies
Highlighted
Community Manager
10 Views

Hello Melvin_Edwards_II,

 

 

Please correct me if I'm wrong, you created a script which creates some sort of file, let's say a log file, and store this log in Edison's internal memory, right?

 

 

If so, where that "log file" is would depend on the script itself. I don't know how you wrote your code so I might be mistaken but usually when you set the file's name, you can add the entire path where you want it to be stored and if that path is not specified, generally the file is created in the same directory where the script is stored.

 

 

It would be helpful to see your script in case the information above doesn't clear your doubts. I hope this information was of help. Let me know.

 

-Peter.
0 Kudos
Highlighted
Community Manager
10 Views

Hi Melvin_Edwards_II,

 

 

Do you have any updates about this?

 

 

-Peter.
0 Kudos
Highlighted
Community Manager
10 Views

Hello Peter,

Thank you for your help, it is greatly appreciated. I included the path that I would like the log file to be stored when i created an object for writing to the file. There are no compiler errors, it runs. I just can't seem to find the file.

Here is my script written in python

# !/usr/bin/python

import mraa

import time

soundpoints = open("C:\Users\Melvin\EdisonFiles\soundpoints.txt", "w")

soundsen = mraa.Aio(0) # Using ADC pin 0

s = 0

totalsound = 0

while True:

for s in range(0,100)

sound = soundsen.read()

totalsound = sound + totalsound

totalsound = totalsound/100

soundpoints.write(" " + str(totalsound))

0 Kudos
Highlighted
Community Manager
10 Views

I believe I was not understanding what you're trying to do. I thought you were trying to store the file within your Edison's internal memory. However, it looks like you are trying to send the file to your PC, is that right?

 

 

If so, you should store the file in your Edison and then send it your PC. Perhaps you can use this document to do it /docs/DOC-109932 https://communities.intel.com/docs/DOC-109932.

 

 

Let me know if that is what you're trying to do and if the document is helpful for you.

 

-Peter.
0 Kudos
Highlighted
Community Manager
10 Views

Hello Peter,

Is there anything on how to create a file in the source code and save to the intel edison itself then?

Thanks,

Melvin

0 Kudos
Highlighted
Community Manager
10 Views

Hi Melvin_Edwards_II,

 

 

I wrote this simple code trying to exemplify how to store data into file:

 

 

import time

 

x = 0

 

f = open('/home/root/test.txt','w')

 

while x < 15:

 

print x

 

x += 1

 

f.write(str(x)+"\n")

 

time.sleep(1)

 

 

As you can see it stores the file in the /home/root directory, your code is not that different from my example, after this you should send it to your PC, you can do it with the guide I sent you earlier.

 

Let me know if it helps you.

 

-Peter.
0 Kudos
Highlighted
Community Manager
10 Views

Hello Peter,

I have typed in the code but I don't know where the file is being stored. The code I pasted did not give me any errors so it probably created the file but I don't know where that file is stored, even though I typed a path in the open command it is not stored there.

-Melvin

0 Kudos
Highlighted
Community Manager
10 Views

What is confusing is that if I typed a similar code into my compiler in my computer it will create the file at the correct location but on the intel edison it creates a file elsewhere I assume.

-Melvin

0 Kudos
Highlighted
Community Manager
10 Views

That is strange, everything seems to be working fine for me, check my screenshot bellow:

Could you post a screenshot of what's happening to you?

 

-Peter.
0 Kudos
Highlighted
Community Manager
10 Views

Hi Melvin,

 

 

Do you have any update about this? Do you still need help?

 

 

-Peter.
0 Kudos