This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Timer | |
import requests | |
import pandas as pd | |
from time import localtime, strftime | |
def update(): | |
getData() | |
set_timer() | |
def set_timer(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import lxml.html as lh | |
import pandas as pd | |
# URL | |
url = '...' | |
# XPath content to collect | |
tags = ['//a[@class="XX"]', \ | |
'//p[@class="XX"]' , \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Read a file and put it into a String variable | |
* @param filename | |
* @return | |
*/ | |
public static String FILE_TO_STRING(String filename) { | |
BufferedReader reader = null; | |
try { | |
InputStream myFile = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename); | |
reader = new BufferedReader(new InputStreamReader(myFile)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Execute a commande line in synchronous call mode | |
* @param line command line | |
* @return result | |
*/ | |
public String EXECUTE_CMD(String line) { | |
String retValue = ""; | |
try { | |
if (!line.equalsIgnoreCase("")) { | |
Process p = Runtime.getRuntime().exec(line); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the real system path of WEB-INF through a servlet | |
* @return répertoire WEB-INF | |
*/ | |
public static String WEBINF_PATH() { | |
String className = JoyConfigfileProvider.class.getName().replaceAll("\\.", "/") + ".class"; | |
// Use the ClassLoader to find the absolute path to this file. | |
URL classPath = JoyConfigfileProvider.class.getClassLoader().getResource(className); | |
//create a new File and go from file to parent file to find the WEB-INF directory | |
File f = new File(classPath.getPath()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Where matplotlib do not work (when using string labels for hist()) | |
from collections import Counter | |
def hist_string(df) : | |
distincts_count = Counter(df) | |
df = pd.DataFrame.from_dict(distincts_count, orient='index') | |
df.plot(kind='bar') | |
hist_string(titanic.Embarked) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The goal here is to create a double histogram with string labels which is not supported yet with the hist() matplotlib function | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from collections import Counter | |
# Dead list | |
l1 = titanic[titanic["Survived"] == 0]["Embarked"].dropna() | |
# Survivor list | |
l2 = titanic[titanic["Survived"] == 1]["Embarked"].dropna() |