On Sat, 9 Sep 2006, Johannes Loehnert wrote:
Understood now. But you cannot store strings and floats in an array simultaneously.
Johannes, I understand. I was thinking of lists, I guess. This is not a problem because I can store a numeric code (1, 2, 3) for each of the two strings and translate them later in the program. They're there for selecting rows. Originally I was going to put the incoming data into a SQLite3 database table, then extract the values using SQL 'select from ... where ...' statements, but I thought that direct application of python datatypes would be more efficient.
Not sure about string.split(), I don't think this is useful (would split into 1-byte chars iirc). You can you use a list comprehension for the data part, like this:
One-byte chars are exactly what I want. That's what is coming from the scanner, in bit-mapped format. What the scanner folks call a column we see as a row on the form. Each 'row' (as we look at the form in portrait orientation) has 12 positions, each with a bit value. There are two bytes encoded there. I'm using the DATA_MAP_ dictionaries to translate from the transmitted bytes to values meaningful to the application.
line = read_data() mapped_vals = [DATA_MAP_7[i:i+2] for i in range(2*7, 2*35)]
DATA_MAP is a dictionary; can I find keys by slicing? If so, it would be [i:i+1] from bytes 12-67.
although I admit it is no very pretty solution. Maybe somebody has a better idea.
You are helping me, but what I'm trying to do is beyond what all my introductory references cover, and I'm not finding clearly presented solutions using Google.
BTW, while having a closer look to your code I noticed that at line 72 = ("line ser.readline") there is a pair of brackets missing. Here is one free of charge: () ;-)
Thank you. I caught that earlier today and fixed it. Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc.(TM) | Accelerator <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863