I am trying to get binary data from text and convert to numpy arrays. I tried these codes:
import numpy as np
import matplotlib.pylab as pl
'''a=open ('rawdata.txt ','r',)
print (a.read())
a.close()'''
data=np.genfromtxt ('rawdata.txt', delimiter=',')
print (data)
time =data [1:,][:,0]
print (time)
voltage=(data [1:,][:,1])
print(voltage)
It is working but there are some problems. It just printes my binary numbers like float:
[[ nan nan nan]
[ 0.00000000e+00 0.00000000e+00 1.01101010e+08]
[ 5.00000000e-04 1.10001000e+05 1.01011000e+08]
[ 1.00000000e-03 1.10000000e+06 1.01011000e+08]
[ 1.50000000e-03 1.00011010e+07 1.00101110e+08]
[ 2.00000000e-03 1.01101110e+07 1.00010111e+08]
[ 2.50000000e-03 1.10111000e+07 0.00000000e+00]
[ 3.00000000e-03 1.11111000e+07 1.01110000e+04]
[ 3.50000000e-03 1.00010101e+08 1.01110000e+05]
[ 4.00000000e-03 1.00101000e+08 1.00010000e+06]
[ 4.50000000e-03 1.00110011e+08 1.01100000e+06]
[ 5.00000000e-03 1.00110111e+08 1.10101000e+06]
[ 5.50000000e-03 1.00110011e+08 1.11100100e+06]
[ 6.00000000e-03 1.00101000e+08 1.00001100e+07]
[ 6.50000000e-03 1.00010101e+08 1.00011110e+07]
[ 7.00000000e-03 1.11111000e+07 1.00101000e+07]
[ 7.50000000e-03 1.10111000e+07 1.00101100e+07]
[ 8.00000000e-03 1.01101110e+07 1.00101000e+07]
[ 8.50000000e-03 1.00011010e+07 1.00011110e+07]
[ 9.00000000e-03 1.10000000e+06 1.00001100e+07]
[ 9.50000000e-03 1.10001000e+05 1.11100100e+06]
[ 1.00000000e-02 0.00000000e+00 1.10101000e+06]
[ 1.05000000e-02 1.00011000e+09 1.01100000e+06]
[ 1.10000000e-02 1.00110000e+09 1.01100000e+06]
[ 1.15000000e-02 1.01000110e+09 1.01100000e+06]
[ 1.20000000e-02 1.01011011e+09 1.01110000e+04]
[ 1.25000000e-02 1.01101110e+09 0.00000000e+00]
[ 1.30000000e-02 1.01111110e+09 1.00010111e+08]
[ 1.35000000e-02 1.10001010e+09 1.00101110e+08]
[ 1.40000000e-02 1.10010100e+09 1.01000100e+08]
[ 1.45000000e-02 1.10011001e+09 1.01011000e+08]
[ 1.50000000e-02 1.10011011e+09 1.01101010e+08]
[ 1.55000000e-02 1.10011001e+09 1.01111001e+08]
[ 1.60000000e-02 1.10010100e+09 1.10000110e+08]
[ 1.65000000e-02 1.10001010e+09 1.10001111e+08]
[ 1.70000000e-02 1.01111110e+09 1.10010100e+08]
[ 1.75000000e-02 1.01101110e+09 1.10010110e+08]
[ 1.80000000e-02 1.01011011e+09 1.10010100e+08]
[ 1.85000000e-02 1.01000110e+09 1.10001111e+08]
[ 1.90000000e-02 1.00110000e+09 1.10000110e+08]
[ 1.95000000e-02 1.00011000e+09 1.01111001e+08]
[ 2.00000000e-02 0.00000000e+00 1.01101010e+08]]
How can I deal with it? My actual rawdata.txt text file:
time(s) ,voltage(V) ,current(A)
0 ,0000000000 ,101101010
0.0005 ,0000110001 ,101011000
0.001 ,0001100000 ,101011000
0.0015 ,0010001101 ,100101110
0.002 ,0010110111 ,100010111
0.0025 ,0011011100 ,000000000
0.003 ,0011111100 ,000010111
0.0035 ,0100010101 ,000101110
0.004 ,0100101000 ,001000100
0.0045 ,0100110011 ,001011000
0.005 ,0100110111 ,001101010
0.0055 ,0100110011 ,001111001
0.006 ,0100101000 ,010000110
0.0065 ,0100010101 ,010001111
0.007 ,0011111100 ,010010100
0.0075 ,0011011100 ,010010110
0.008 ,0010110111 ,010010100
0.0085 ,0010001101 ,010001111
0.009 ,0001100000 ,010000110
0.0095 ,0000110001 ,001111001
0.01 ,0000000000 ,001101010
0.0105 ,1000110001 ,001011000
0.011 ,1001100000 ,001011000
(time, voltage_b, current_b). Then you can treat them accordingly. Treattimeas afloat,voltage_bandcurrent_basstrthen convert them toint.