matplotlib surface plot linewidth wrong - matplotlib

I am trying to plot a surface using matplotlib.
There is problem that, even if I specify the linewidth as zero in the code, the show() displays the correct plot without lines. However the pdf generated still has lines in it.
Can anyone tell how to resolve this problem?
Here is the code that I am using to plot
#!/usr/bin/env python
import numpy as np
from matplotlib import cm
import matplotlib.pyplot as plt
import scipy.ndimage as ndimage
vmaxValue=400
#plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
fileName="test"
csvFile=fileName+".csv"
outputFile=fileName+".pdf"
pgfFile=fileName+".pgf"
data = np.genfromtxt(csvFile)
# Delete the first row and first column.
Z = np.delete(data, (0), axis=0)
Z = np.delete(Z, (0), axis=1)
Z2 = ndimage.gaussian_filter(Z, sigma=0.85, order=0)
X, Y = np.meshgrid(np.arange(1,len(Z[0])+1,1), np.arange(1,len(Z)+1,1))
surf = ax.plot_surface(X, Y, Z2, linewidth=0, cstride=1, rstride=1, cmap=cm.coolwarm, antialiased=False, vmin=0, vmax=vmaxValue)
#plt.colorbar()
fig.colorbar(surf, ax=ax, shrink=0.75,pad=-0.05, aspect=15)
ax.set_zlim(0,vmaxValue)
ax.set_xlabel(r'$\alpha$')
ax.set_ylabel('processors')
ax.set_zlabel('Exploration Time(seconds)')
ax.view_init(20, -160)
fig.savefig(outputFile,format="pdf", bbox_inches='tight')
here is the csv file test.csv
Processors graph1 graph2 graph3 graph4 graph5 graph6 graph7 graph8 graph9 graph10 graph11 graph12 graph13 graph14 graph15 graph16 graph17 graph18 graph19 graph20 graph21 graph22 graph23
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 10 7 190 180 360 180 360 180 360 180 360 180 360 180 360
3 0 0 0 0 0 0 0 0 0 64 52 85 247 274 180 360 360 360 360 360 360 360 360
4 0 0 0 0 0 0 0 0 6 1 1 2 180 180 187 187 180 180 360 360 180 180 360
5 0 0 0 0 0 0 0 0 0 0 180 177 175 180 180 360 360 360 360 360 540 540 360
6 0 0 0 0 0 0 0 1 1 1 1 1 181 181 180 180 180 180 360 360 360 360 180
7 0 0 0 0 0 0 0 8 12 6 6 7 8 8 180 180 180 180 180 180 180 360 180
8 0 0 0 0 0 0 0 0 180 133 175 166 148 180 180 180 180 180 180 180 180 180 360
9 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180 180 180 180 180 360
10 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180 180 180 180 360
11 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180 180 180 360
12 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180 180 180
13 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180 180
14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180 180
15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180 180
16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180 180
17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180 180
18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180 180
19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180 180 180
20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 184 180
21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180 180
22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 180
23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Thanks

Apparently it has to do with your pdf antialiasing.
If you don't mind some extra computation time, this answer suggests that you can get rid of it by plotting the same figure multiple times,
for i in range(k):
ax.plot_surface(X, Y, Z2, linewidth=0, cstride=1, rstride=1, cmap=cm.coolwarm, antialiased=False, vmin=0, vmax=vmaxValue)
Note k=2 worked pretty well for me. I wouldn't say it doubles your file size every time you do it, but the size raises by a noticeable amount
If you feel more adventurous, you can check this answer regarding the same issue with contourf. In summary:
for c in cnt.collections:
c.set_edgecolor("face")
Unfortunately matplotlib 3D Objects have no attribute collections so it won't work right away, but hopefully this gives you an inspiration

Related

Count the day before and the present day

I have a code to count every route from bus by departure date, but i need to count the day before from route 148 plus the count of the route 139 for any day.
I have a view with variables: DEP_DATE (DATE), DepartureDate (Datetime), Routes (Numeric) like this
DEP_DATE DepartureDate Route= 139 Route= 148 Route=129 Route=61 Route=134 Route=60
08/02/2019 2019-02-08T15:00:00 0 0 0 0 0 0
08/02/2019 2019-02-08T10:45:00 0 0 0 0 0 0
08/02/2019 2019-02-08T08:30:00 0 0 0 0 0 0
08/02/2019 2019-02-08T08:15:00 0 0 0 0 0 0
08/02/2019 2019-02-08T21:00:00 0 0 0 0 0 0
08/02/2019 2019-02-08T13:00:00 0 0 0 0 0 0
08/02/2019 2019-02-08T06:30:00 0 0 0 11 0 0
08/02/2019 2019-02-08T19:00:00 0 0 21 0 0 0
08/02/2019 2019-02-08T06:00:00 0 0 0 0 10 13
08/02/2019 2019-02-08T17:30:00 0 0 2 0 0 0
08/02/2019 2019-02-08T05:30:00 1 0 0 0 0 0
08/02/2019 2019-02-08T14:45:00 0 0 0 0 0 0
08/02/2019 2019-02-08T07:00:00 0 0 0 0 0 0
09/02/2019 2019-02-09T20:15:00 0 0 0 0 0 0
09/02/2019 2019-02-09T22:00:00 0 2 0 0 0 0
09/02/2019 2019-02-09T20:30:00 0 0 8 0 0 0
09/02/2019 2019-02-09T08:30:00 0 0 0 0 0 0
09/02/2019 2019-02-09T07:00:00 0 0 0 12 0 0
09/02/2019 2019-02-09T19:00:00 0 0 12 0 0 0
09/02/2019 2019-02-09T06:00:00 0 0 0 0 20 7
09/02/2019 2019-02-09T15:00:00 0 0 0 0 0 0
09/02/2019 2019-02-09T06:30:00 0 0 0 0 0 0
09/02/2019 2019-02-09T08:15:00 0 0 0 0 0 0
09/02/2019 2019-02-09T18:15:00 0 0 0 0 0 0
09/02/2019 2019-02-09T14:45:00 0 0 0 0 0 0
09/02/2019 2019-02-09T13:00:00 0 0 0 0 0 0
10/02/2019 2019-02-10T21:00:00 0 0 0 0 0 0
10/02/2019 2019-02-10T10:45:00 0 0 0 0 0 0
10/02/2019 2019-02-10T06:00:00 0 0 0 0 11 11
10/02/2019 2019-02-10T13:00:00 0 0 0 0 0 0
10/02/2019 2019-02-10T08:30:00 0 0 0 0 0 0
10/02/2019 2019-02-10T08:15:00 0 0 0 22 0 0
10/02/2019 2019-02-10T19:00:00 0 0 21 0 0 0
10/02/2019 2019-02-10T07:00:00 0 0 0 0 0 0
10/02/2019 2019-02-10T20:15:00 0 0 0 0 0 0
10/02/2019 2019-02-10T15:00:00 0 0 0 0 0 0
10/02/2019 2019-02-10T20:30:00 0 1 2 0 0 0
10/02/2019 2019-02-10T06:30:00 0 0 0 0 0 0
10/02/2019 2019-02-10T18:15:00 0 0 0 10 0 0
11/02/2019 2019-02-11T19:00:00 0 0 32 0 0 0
11/02/2019 2019-02-11T08:30:00 0 0 0 0 0 0
11/02/2019 2019-02-11T06:00:00 0 0 0 0 14 12
11/02/2019 2019-02-11T00:45:00 0 0 0 0 0 0
11/02/2019 2019-02-11T15:00:00 0 0 0 0 0 0
11/02/2019 2019-02-11T08:15:00 0 0 0 0 0 0
11/02/2019 2019-02-11T13:00:00 0 0 0 0 0 0
11/02/2019 2019-02-11T06:30:00 0 0 0 0 0 0
11/02/2019 2019-02-11T07:00:00 0 0 0 0 0 0
11/02/2019 2019-02-11T10:45:00 0 0 0 0 0 0
12/02/2019 2019-02-12T08:30:00 0 0 0 0 0 0
12/02/2019 2019-02-12T13:00:00 0 0 0 0 0 0
12/02/2019 2019-02-12T06:00:00 0 0 0 0 10 8
12/02/2019 2019-02-12T15:00:00 0 0 0 0 0 0
12/02/2019 2019-02-12T10:45:00 0 0 0 0 0 0
12/02/2019 2019-02-12T07:00:00 0 0 0 0 0 0
12/02/2019 2019-02-12T14:45:00 0 0 0 15 0 0
12/02/2019 2019-02-12T19:00:00 0 0 14 0 0 0
12/02/2019 2019-02-12T22:00:00 0 2 0 0 0 0
13/02/2019 2019-02-13T13:00:00 0 0 0 0 0 0
13/02/2019 2019-02-13T18:15:00 0 0 0 0 0 0
13/02/2019 2019-02-13T08:15:00 0 0 0 0 0 0
13/02/2019 2019-02-13T20:15:00 0 1 0 0 0 0
13/02/2019 2019-02-13T15:00:00 0 0 0 0 0 0
13/02/2019 2019-02-13T14:45:00 0 0 0 0 0 0
13/02/2019 2019-02-13T08:30:00 0 0 0 0 0 0
13/02/2019 2019-02-13T07:00:00 0 0 0 0 0 0
13/02/2019 2019-02-13T06:00:00 0 0 0 0 7 7
13/02/2019 2019-02-13T21:00:00 0 0 0 0 0 0
13/02/2019 2019-02-13T06:30:00 0 0 0 3 0 0
13/02/2019 2019-02-13T19:00:00 0 0 24 0 0 0
14/02/2019 2019-02-14T18:15:00 0 0 0 0 0 0
14/02/2019 2019-02-14T20:30:00 0 0 3 0 0 0
14/02/2019 2019-02-14T07:00:00 0 0 0 0 0 0
14/02/2019 2019-02-14T06:00:00 0 0 0 0 4 2
14/02/2019 2019-02-14T15:00:00 0 0 0 10 0 0
14/02/2019 2019-02-14T19:00:00 0 0 10 0 0 0
14/02/2019 2019-02-14T13:00:00 2 0 0 0 0 0
14/02/2019 2019-02-14T08:30:00 0 0 0 0 0 0
And have my code that i made is like this:
SELECT
DEP_DATE,
COUNTIF( RouteId = 139) + COUNTIF( RouteId = 148 AND DepartureDate =
DATETIME_SUB(departureDate, INTERVAL 1 DAY)) AS BUS_1,
COUNTIF( RouteId = 134 ) + COUNTIF( RouteId = 60 ) AS BUS_2,
COUNTIF( RouteId = 134 AND EXTRACT(HOUR FROM DepartureDate) = 6) +
COUNTIF( RouteId = 60 AND EXTRACT(HOUR FROM DepartureDate) = 6) AS
BUS_3,
FROM
`project.dataset.view`
WHERE
DepartureDate >
DATETIME_TRUNC(DATETIME_SUB(CURRENT_DATETIME("America/Lima"), INTERVAL 3
DAY),DAY)
GROUP BY
DEP_DATE
My results are like this
DEP_DATE Bus_1 Bus_2 Bus_3 Explanation_Bus_1: Route_139 Route_148
08/02/2019 1 34 23 1 0
09/02/2019 2 32 27 0 2
10/02/2019 1 45 22 0 1
11/02/2019 0 42 26 0 0
12/02/2019 2 29 18 2 0
13/02/2019 0 27 14 0 1
14/02/2019 3 23 6 2 0
But what i expect my count on "Bus_1" like this:
DEP_DATE Bus_1 Bus_2 Bus_3 Explanation_Bus_1: Route_139 Route_148
08/02/2019 1 34 23 1 0
09/02/2019 0 32 27 0 2
10/02/2019 2 45 22 0 1
11/02/2019 1 42 26 0 0
12/02/2019 2 29 18 2 0
13/02/2019 0 27 14 0 1
14/02/2019 3 23 6 2 0
Every count of the route 148 has to be count the day after in the Bus 1
You would need to check if the date is Friday, Wednesday or Saturday. If it is one of those days, then calculate else default to 0.
Big Query Conditional Expressions: https://cloud.google.com/bigquery/docs/reference/standard-sql/conditional_expressions
Big Query Date Functions: https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions
DAYOFWEEK: Returns values in the range [1,7] with Sunday as the first day of the week.
Try this:
SELECT
T1.DEP_DATE,
T2.BUS_1 AS BUS_1,
COUNTIF( RouteId = 134 ) + COUNTIF( RouteId = 60 ) AS BUS_2,
COUNTIF( RouteId = 134 AND EXTRACT(HOUR FROM DepartureDate) = 6) +
COUNTIF( RouteId = 60 AND EXTRACT(HOUR FROM DepartureDate) = 6) AS
BUS_3,
FROM
`project.dataset.view` T1
LEFT JOIN (
SELECT
DATEADD(DEP_DATE, 1, DAY) AS DEP_DATE,
COUNTIF(RouteId = 139) + COUNTIF(RouteId = 148) AS BUS_1
FROM project.dataset.view
GROUP BY DEP_DATE
) T2
ON T1.DEP_DATE = T2.DEP_DATE
WHERE
DepartureDate >
DATETIME_TRUNC(DATETIME_SUB(CURRENT_DATETIME("America/Lima"), INTERVAL 3
DAY),DAY)
GROUP BY
T1.DEP_DATE, T2.BUS_1

What does each number represents in MNIST?

I have successfully downloaded MNIST data in files with .npy extension. When I print the few columns of first image. I get the following result. What does each number represent here?
a= np.load("training_set.npy")
print(a[:1,100:200])
print(a.shape)
[[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 18
18 18 126 136 175 26 166 255 247 127 0 0 0 0 0 0 0 0
0 0 0 0 30 36 94 154 170 253 253 253 253 253 225 172 253 242
195 64 0 0 0 0 0 0 0 0]]
(60000, 784)
[[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 18
18 18 126 136 175 26 166 255 247 127 0 0 0 0 0 0 0 0
0 0 0 0 30 36 94 154 170 253 253 253 253 253 225 172 253 242
195 64 0 0 0 0 0 0 0 0]]
These are the intensity values (0-255) for each of the 784 pixels (28x28) of a MNIST image; the total number of training images is 60,000 (you'll find 10,000 more images in the test set).
(60000, 784) means 60,000 samples (images), each one consisting of 784 features (pixel values).

How can I change my index vector into sparse feature vector that can be used in sklearn?

I am doing a News recommendation system and I need to build a table for users and news they read. my raw data just like this :
001436800277225 [12,456,157]
009092130698762 [248]
010003000431538 [361,521,83]
010156461231357 [173,67,244]
010216216021063 [203,97]
010720006581483 [86]
011199797794333 [142,12,86,411,201]
011337201765123 [123,41]
011414545455156 [62,45,621,435]
011425002581540 [341,214,286]
the first column is userID, the second column is the newsID.newsID is a index column, for example, after transformation, [12,456,157] in the first row means that this user has read the 12th, 456th and 157th news (in sparse vector, the 12th column, 456th column and 157th column are 1, while other columns have value 0). And I want to change these data into a sparse vector format that can be used as input vector in Kmeans or DBscan algorithm of sklearn.
How can I do that?
One option is to construct the sparse matrix explicitly. I often find it easier to build the matrix in COO matrix format and then cast to CSR format.
from scipy.sparse import coo_matrix
input_data = [
("001436800277225", [12,456,157]),
("009092130698762", [248]),
("010003000431538", [361,521,83]),
("010156461231357", [173,67,244])
]
NUMBER_MOVIES = 1000 # maximum index of the movies in the data
NUMBER_USERS = len(input_data) # number of users in the model
# you'll probably want to have a way to lookup the index for a given user id.
user_row_map = {}
user_row_index = 0
# structures for coo format
I,J,data = [],[],[]
for user, movies in input_data:
if user not in user_row_map:
user_row_map[user] = user_row_index
user_row_index+=1
for movie in movies:
I.append(user_row_map[user])
J.append(movie)
data.append(1) # number of times users watched the movie
# create the matrix in COO format; then cast it to CSR which is much easier to use
feature_matrix = coo_matrix((data, (I,J)), shape=(NUMBER_USERS, NUMBER_MOVIES)).tocsr()
Use MultiLabelBinarizer from sklearn.preprocessing
from sklearn.preprocessing import MultiLabelBinarizer
mlb = MultiLabelBinarizer()
pd.DataFrame(mlb.fit_transform(df.newsID), columns=mlb.classes_)
12 41 45 62 67 83 86 97 123 142 ... 244 248 286 341 361 411 435 456 521 621
0 1 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 1 0 0
1 0 0 0 0 0 0 0 0 0 0 ... 0 1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 1 0 0 0 0 ... 0 0 0 0 1 0 0 0 1 0
3 0 0 0 0 1 0 0 0 0 0 ... 1 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 1 0 0 ... 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 1 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
6 1 0 0 0 0 0 1 0 0 1 ... 0 0 0 0 0 1 0 0 0 0
7 0 1 0 0 0 0 0 0 1 0 ... 0 0 0 0 0 0 0 0 0 0
8 0 0 1 1 0 0 0 0 0 0 ... 0 0 0 0 0 0 1 0 0 1
9 0 0 0 0 0 0 0 0 0 0 ... 0 0 1 1 0 0 0 0 0 0

Pharo FileSystem: How do I write a binary file?

TabularResources testExcelSheet
from this project gives me a binary representation in a literal array of an Excel file.
````
testExcelSheet
^ #[80 75 3 4 20 0 6 0 8 0 0 0 33 0 199 122 151 144 120 1 0 0 32 6 0 0 19 0 8 2 91 67 111 110 116 101 110 116 95 84 121 112 101 115 93 46 120 109 108 32 162 4 2 40 160 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .....
....0 109 108 80 75 1 2 45 0 20 0 6 0 8 0 0 0 33 0 126 148 213 45 209 1 0 0 250 10 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 233 36 0 0 120 108 47 99 97 108 99 67 104 97 105 110 46 120 109 108 80 75 5 6 0 0 0 0 13 0 13 0 74 3 0 0 232 38 0 0 0 0]
````
Question
How do I write this to the disk to see which kind of file it is?
Answer
(by Esteban, edited)
./TabularATest1.xlsx' asFileReference writeStreamDo: [ :stream |
stream
binary;
nextPutAll: self testExcelSheet ]
Easiest way to do that is something like this:
'./file.bin' asFileReference writeStreamDo: [ :stream |
stream
binary;
nextPutAll: #[1 2 3 4 5 6 7 8 9 0] ]
So the trick is just telling to the stream "be a binary file" :)

in a word macro delete everything that does not start with one of two strings

I have a data file that contains a lot of extra data. I want to run a word macro that only keeps 5 lines (I could live with 6 if it makes it easier)
I found how to delete a row if it contains a string.
I want to keep the paragraphs that start with:
Record write time
Headband impedance
Headband Packets
Headband RSSI
Headband Status
I could live with keeping
Headband ID
I tried the following macro, based on a sample I saw here. But, I am getting an error.
Sub test()
'
' test Macro
Dim search1 As String
search1 = "record"
Dim search2 As String
search2 = "headb"
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs
Dim txt As String
txt = para.Range.Text
If Not InStr(LCase(txt), search1) Then
If Not InStr(LCase(txt), search2) Then
para.Range.Delete
End If
Next
End Sub
The error is: next without For.
I know that there may be a better way, and an open to any fix.
Sample data:
The data is:
ZEO Start data record
----------------
Record write time: 10/14/2014 20:32
Factory reset date: 10/14/2014 20:23
Headband ID: 01/01/1970 18:32
Headband impedance: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 241 247 190 165 154 150 156 162 177 223 202
Headband Packets: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 21 4 30 3 3 3 9 4 46 46 1
Headband RSSI: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 0 0 6 254 254 250 5 255 4 3 249
Headband Status: 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 169 170 170
Hardware ID: 2
Software ID: 43
Sensor Life Reset date: Not recorded
sleep Stat Reset date: 10/14/2014 20:18
Awakenings: 0
Awakenings Average: 0
Start of night: 10/14/2014 20:28
End of night: 10/14/2014 20:32
Awakenings: 0
Awakenings Average: 0
Time in deep: 0
Time in deep average: 0
There is an End If missing. Add this immediately after the first End If - do you get the same error?
Update:
There is also an error in the If conditions. Check the InStr reference for return values.
You need to use something like If Not InStr(...) = 1 Then on both if statements.