[Tutor] Need help appending data to a logfile
Matt D
md123 at nycap.rr.com
Thu Jun 27 16:55:50 CEST 2013
On 06/27/2013 10:36 AM, Matt D wrote:
>
>>
>> You asked about a "save-as" feature. Why isn't that as simple as
>> copying the current contents of the saved csv file? Or do you not know
>> how you would go about copying?
>>
>
> Hi. So I have the logger working, meaning the correct data is being
> written to the 'internal' file 'logfile.txt' which is opened like this:
>
> self.logfile = open('logfile.txt', 'a')
>
> And I have the button that starts the file dialog like this:
>
> #open file dialog -----------------------------
> def openFile(self, evt):
> with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
> "*.*", wx.OPEN) as dlg:
> if dlg.ShowModal() == wx.ID_OK:
> path = dlg.GetPath()
> mypath = os.path.basename(path)
> with open(mypath, "a") as f:
>
>
> Is there a simple way to copy what is in the 'internal' logfile.txt to
> the file that the user chooses from the button?
> Thanks!
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
I forgot to mention i have the 'with open(mypath, "a") as f: commented
out because it was making an indentation error that i could not fix.
More information about the Tutor
mailing list