Warning: I am newbie to Python, Pandas, and PySerial....
I am reading values from an Excel spreadsheet using Pandas. The values in Excel are stored as Text, but contain both alphabetical and numeric characters. see Snip of Excel data
I import these using Pandas command mydata = pd.read_excel (*path etc goes here*)
<<< (no problems are encountered with this function)
I can then print them using print(mydata)
....and the output looks the same as it appears in the Excel spreadsheet (i.e., there are no extra characters):
0 MW000000007150000300000;
1 MW000100009850000200000;
2 MW000200009860000200000; #<<<<<<<< *Notice that there are NO square brackets and no extra Quotes*.
To send these data via the PySerial function serial.write
to my RS-232 linked device, I am looping through the values which must (as I understand it...) be in a LIST format. So, I convert the data-field mydata
into a LIST, by using the command Allocation_list=mydata.values.tolist()
If I print(Allocation_list)
, I find many square brackets and single quotes have been added, as you can see here:
Allocation_list =([['MW000000007150000300000;'], ['MW000100009850000200000;'], ['MW000200009860000200000;'], ['MW000300009870000200000;'], ['MW000400009880000200000;'], ['MW000500009890000200000;']])
These square brackets are NOT ignored when I <<serial.write>> the values in the LIST to my RS-232 device.
In fact, the values are written as (binary versions of....)
0 memory written as ['MW000000007150000300000;']
1 memory written as ['MW000100009850000200000;']
2 memory written as ['MW000200009860000200000;']
3 memory written as ['MW000300009870000200000;']
4 memory written as ['MW000400009880000200000;']
5 memory written as ['MW000500009890000200000;']
Unfortunately, for the RS-232 device to accept each of the lines written to it as a acceptable command, they must be in the precise command format for that device, which looks like
MW000000007150000300000; <<<<< the semi-colon is a required part of the syntax
So, the square brackets and the Quotation marks have to be removed, somehow.
Any help with this peculiar problem would be appreciated, as I have tried several of the methods described in other 'threads', and none of them seem to work properly because my datafield is a set of strings (which are converted to bits ONLY as they are about to be written to the RS-232 device). M