> > *It seems likely that I'm just doing something wrong, some simple thing > and perhaps I simply cannot read and write from Python to my text file, but > that seems crazy.* >
The thought that you're doing something wrong did cross my mind, but I usually try to give a person a benefit of the doubt, until their skill level makes its self plain. Maybe if you show us what you have for a source file someone can figure what's going on. I can actually read through Python quite well despite never having write a single line of python myself. The syntax is not too far off other language I've used in the past. On Tue, Apr 5, 2016 at 5:54 PM, John Baker <[email protected]> wrote: > Thanks William but although I have done some C programming and have read > and written files in C, I don't know how to get C running on the > Beaglebone. Hopefully I haven't painted myself in a corner but my Python > program is running well otherwise. I am doing some Fuzzy Logic control for > a paint flow project, have a GUI with an animated graph using matplotlib > and Tkinter, am outputting a PWM signal and measuring the filtered PWM > voltage back into the controller software with the BBB ADC. It's all > looking good until I decided to write a very short text file for the system > gain, just a single number, but am stymied by it. I just now made my own > text file using nano and see that the file is in my /home/baker folder but > my Python program cannot find it, cannot read it. > It seems likely that I'm just doing something wrong, some simple thing and > perhaps I simply cannot read and write from Python to my text file, but > that seems crazy. > John > > > On 4/5/2016 5:34 PM, William Hermans wrote: > > John, the only other thign I can think of which may be a possibility. Is > that your eMMC might perhaps be in read only mode ? Which does not explain > the no error message thing, but why don't you try to write a simple C app > to do the same and see what happens ? > > On Tue, Apr 5, 2016 at 5:20 PM, John Baker <[email protected]> > wrote: > >> I made a new folder /home/baker and then changed my write open() command >> to f = open('/home/baker/MyFile.txt', w) and the read open command to f = >> open('/home/baker/MyFile.txt', w) but still am not able to create and write >> to the MyFile.txt. Now the getcwd() command tells me that the cwd is >> /home/baker. Also not getting any error message even for writing or >> reading, just the exception to reading the file that it cannot find the >> file. No exception when I try to write to the file. I am running my Python >> program with sudo python myprogram.py. I tried changing the permissions to >> my /home/baker directory with "sudo chmod -R 777 /home/baker" but WinSCP >> still says the owner is root and still my Python program cannot write a >> text file to /home/baker. >> >> So I'm at wits end (a short trip to be sure) and cannot figure out how to >> write the data file. >> John >> >> On Tuesday, April 5, 2016 at 4:46:17 PM UTC-7, John Baker wrote: >>> >>> Thanks Paul. >>> getcwd() tells me that my cwd is /home/debian/Desktop when I use f = >>> open('MyFile.txt', w). I am using Try/Except and not getting an exception >>> with the open() statement. Perhaps I can't write a text file to the >>> Desktop, but it seems like it should give me an error message. >>> John >>> >>> On 4/5/2016 3:19 PM, Paul Wolfson wrote: >>> >>> python >>> >>> import os >>> >>> os.getcwd() >>> 'home/pwolfson' >>> >>> >>> >>> >>> ------------------------------------------------- >>> Paul Wolfson, Ph.D., TX LPI, #A17473 >>> Dallas Legal Technology >>> 3402 Oak Grove Avenue, Suite 300-A >>> Dallas, Texas 75204-2353 >>> >>> >>> *214-257-0984 <214-257-0984> (Tel) 214-838-7220 <214-838-7220> (Fax) >>> Send me an email.* >>> ------------------------------------------------- >>> The contents of this email are confidential to the sender and the >>> ordinary user of the email address to which it was addressed, and may also >>> be privileged. If you are not the addressee of the email, you may not >>> copy, forward, disclose or otherwise use it or any part of it in any form >>> whatsoever. If you have received this email in error, please advise the >>> sender at 214-257-0984. Thank you. >>> ------------------------------------------------- >>> >>> On Tue, Apr 5, 2016 at 6:13 PM, William Hermans <[email protected]> >>> wrote: >>> >>>> *That's what I figured William. As far as I can tell, I am doing the >>>>> open and write and read like I have with C and as described in >>>>> <https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files>https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files >>>>> <https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files>. >>>>> However, I am not getting any error message when I do the open for writing >>>>> and do the write, just that the file is not getting created and written. >>>>> It >>>>> should be so straightforward but it's not working.* >>>>> >>>> >>>> Does this file already exist ? You should check the documentation for >>>> the file write() method and see what all is required for the method to work >>>> correctly. Also, as I said I'm no python developer, but the code shown >>>> there is really bad form. There is no error checking on the file object >>>> when attempting the open() call. In C this would be done by checking the >>>> value of f, but I'm not even sure this is possible in python. >>>> >>>> So I'd attempt to help you trouble shoot this by writing code myself, >>>> here, and testing. But I'm very "allergic" to python. Or more correctly, >>>> I'm getting old, and set in my ways, and python just is not in my future >>>> plans. *ever* . . . >>>> >>>> On Tue, Apr 5, 2016 at 3:05 PM, John Baker <[email protected]> >>>> wrote: >>>> >>>>> That's what I figured William. As far as I can tell, I am doing the >>>>> open and write and read like I have with C and as described in >>>>> <https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files> >>>>> https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files. >>>>> However, I am not getting any error message when I do the open for writing >>>>> and do the write, just that the file is not getting created and written. >>>>> It >>>>> should be so straightforward but it's not working. >>>>> John >>>>> >>>>> On Tuesday, April 5, 2016 at 2:57:02 PM UTC-7, William Hermans wrote: >>>>>> >>>>>> I'm not a python developer, but actually have done this many times in >>>>>> C. So I can tell you this with certainty. This is done no different than >>>>>> it >>>>>> is done on any Linux system. >>>>>> >>>>>> The point here is that you should go out and find any good python >>>>>> tutorial, that covers writing to a file, and follow it. >>>>>> >>>>>> On Tue, Apr 5, 2016 at 1:43 PM, John Baker <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> I want to store a little data on the eMMC from my Python code. My >>>>>>> program is not getting errors when I try to write a very short data file >>>>>>> but it doesn't actually seem to write it as I cannot read it back. I am >>>>>>> using >>>>>>> f = open('MyFile.txt', w) >>>>>>> >>>>>>> or >>>>>>> f = open('/home/debian/Desktop/MyFile.txt', w) >>>>>>> >>>>>>> or >>>>>>> f = open('MyFile.txt', r) >>>>>>> >>>>>>> or >>>>>>> f = open('/home/debian/Desktop/MyFile.txt', r) >>>>>>> >>>>>>> to open the file and am not getting any errors but Python is not >>>>>>> finding the file and I cannot find the file with a search from WinSCP. >>>>>>> >>>>>>> So how to create a data file and where does it go? >>>>>>> >>>>>>> Thanks, >>>>>>> John >>>>>>> -- >>>>>>> For more options, visit <http://beagleboard.org/discuss> >>>>>>> http://beagleboard.org/discuss >>>>>>> --- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "BeagleBoard" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to [email protected]. >>>>>>> For more options, visit <https://groups.google.com/d/optout> >>>>>>> https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>>> For more options, visit <http://beagleboard.org/discuss> >>>>> http://beagleboard.org/discuss >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "BeagleBoard" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> For more options, visit <https://groups.google.com/d/optout> >>>>> https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>>> For more options, visit <http://beagleboard.org/discuss> >>>> http://beagleboard.org/discuss >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "BeagleBoard" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit <https://groups.google.com/d/optout> >>>> https://groups.google.com/d/optout. >>>> >>> >>> -- >>> For more options, visit <http://beagleboard.org/discuss> >>> http://beagleboard.org/discuss >>> --- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "BeagleBoard" group. >>> To unsubscribe from this topic, visit >>> <https://groups.google.com/d/topic/beagleboard/4eMyTYs_lnw/unsubscribe> >>> https://groups.google.com/d/topic/beagleboard/4eMyTYs_lnw/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> For more options, visit <https://groups.google.com/d/optout> >>> https://groups.google.com/d/optout. >>> >>> >>> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to the Google Groups >> "BeagleBoard" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to a topic in the > Google Groups "BeagleBoard" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beagleboard/4eMyTYs_lnw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
