Case:
fig.show() using Plotly does not work in jupyter
What to do:
Force rendering adding this line just before fig.show() using pio
Example:
import plotly.io as pio
pio.renderers.default = 'iframe'
fig.show()
Listo!
Site dedicated mainly to internetworking. The goal is to share experiences, teach IP, IPv6. Talk about Linux, IP services, servers, promote IPv6 adoption, routing protocols, security and in some cases just some thoughts. Keywords: linux, cisco, ospf, bgp, eigrp, ip, ipv6, sla, link, routers, routings, telco, telecommunications, security, ipv4
Case:
fig.show() using Plotly does not work in jupyter
What to do:
Force rendering adding this line just before fig.show() using pio
Example:
import plotly.io as pio
pio.renderers.default = 'iframe'
fig.show()
Listo!
Situation:
Reading a text file in python3 (csv or txt) there is a character that can be appreciated using "more" in terminal but in python3 the situation is more complicated.
Example:
$ more epa.csv
<U+FEFF>the text
Problem:
Python3 reads the file well, it doesn't throw an error, but that invisible "character" remains in the variables, the texts, etc. and can cause some inconvenience.
Solution:
The solution is to read the file and specify the encoding, something as simple as:
FILENAME="epa.csv"
with open(FILENAME, encoding='utf-8-sig') as file:
for line in file:
print(line)
Explanation (taken from: https://stackoverflow.com/questions/17912307/u-ufeff-in-python-string):
The Unicode character U+FEFF is the byte order mark, or BOM, and is used to tell the difference between big- and little-endian UTF-16 encoding.
Good luck,
#!/usr/bin/python3.3
#The objetive of this script is to find all tables in a MYSQL DB and opmitize all of them
import dbconnect
import time
from datetime import datetime
## // VARIABLE DECLARATION ##//
startTime = datetime.now()
conn = dbconnect.dbconnect()
conn.autocommit(True)
cur = conn.cursor()
print ("Starting time: ", startTime)
SQLQUERY=("SHOW TABLES") #Find every table in the DB
cur.execute(SQLQUERY)
tables = cur.fetchall()
if len(tables)>0: #Prevent there are not tables in the list
for table in tables: #For every table in the DB
try:
SQLQUERY="OPTIMIZE TABLE "+ table[0] #Construct the SQL QUERY
print (" Optimizing", table[0])
cur.execute(SQLQUERY)
except:
pass
print ("Script execution time:",datetime.now()-startTime)
print ("Ending time: ", datetime.now())
print ("******** ****** ")
(I guess there are many other ways to do this, even more elegant)