473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

saving a text file

any idea how to automatically save to a text file?
here's what the program do:

first, data is read from the serial port every fixed lenght of time
the data will then be put to a table,
now, every serial read, a table will be created for the data that will
be gathered (one window for each table)
to avoid showing in too many windows, each table will be automatically
saved as a txt file after every 5 tables created.
the txt file will be named after the time it was taken (say from the
system clock)

thanks for your help and more power...
Jul 18 '05 #1
2 1968
Hmmm...... I can't guess what format you will create the 'tables' in,
or what format you want to save them in. You need the pyserial module
to read data from the serial port - I assume you have already
discovered that ?

Writing a text file to disc is *extremely* trivial.... Turning a
table - (list ?) - into a single string for writing to file is also
*extremely* trivial....

Are you familiar with the basic python data types, built-in functions,
and string methods ?

If not - please try the Python tutorial at www.python.org - it won't be
very long before you can do this. If your real problem is more
difficult (i.e. related to pyserial or choosing a data format) then
please provide more details.

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #2
Jan Rienyer Gadil wrote:
any idea how to automatically save to a text file?


What does 'automatically' mean ?-)

AFAIK, the best way to write something to a file is to
* open the file in write mode
* write your data to the file
* close the file

Hopefully this is quite simple.

f = File('myfile.txt', 'w')
f.write(my_data)
f.close()

You'll of course need to add some code to handle IOErrors...

(snip)

HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: terrorix | last post by:
I want to save uploaded file to disk. I have this construction: HttpPostedFile myFile = ((HttpRequest)Request).Files; if (myFile != null) { string fn =...
0
by: Karen Grube | last post by:
Hi! I hate to bother you all with this, but I don't know how best to approach a particular task. Here's the deal: Once a month I personally (that is, in my own personal inbox on my...
5
by: Steve Marshall | last post by:
Hi all, I am converting an app which used a picturebox to draw graphs etc onto, then saved them to a file. I can certainly draw things onto a picturbox in VB.NET, but how do I save them to a...
4
by: Dixie | last post by:
I have a spreadsheet that uses VBA code in Access to save itself as a text file. The line is as follows. xl.ActiveSheet.SaveAs CurrentProject.Path & "\Reports\" & DLookup("", "tblButtons",...
5
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the...
8
by: Yu SONG | last post by:
Hi all, What would be the most efficient way to save an array of floats to a file (in text format)? At the moment, my code looks like: /* * Saving an array of floats to a file
0
Ajm113
by: Ajm113 | last post by:
Contributing To: Saving RichTextBox from Tab Control Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread?...
3
by: pozze | last post by:
Hi, I've just made the change from ASP to .net. I have a file (code below) that saves a user submitted file to a MS SQL 2005 database. It collects the file name, file size, file type, and lastly...
9
by: Yamasassy | last post by:
HI im having problems to saving to a .txt file, i need to be able to store a number of employees to this file (and beable to open and these files to load in to text boxes)and retrieve then for later...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.