Skip to content

Instantly share code, notes, and snippets.

View PiotrKrosniak's full-sized avatar
🏠
Working from home

Peter Kross PiotrKrosniak

🏠
Working from home
View GitHub Profile
import tensorflow as tf
import pickle
import pandas as pd
#Read DataFrame from CSV
csv_file = pd.read_csv('./results/ADM_VRP_20_1024/data_pak_calc.csv')
df = csv_file[['latitude','longitude', 'demand']].head(10)
def create_data(graph_size, num_samples, is_save=True, filename=None, is_return=False, seed=1234):
"""Generate validation dataset (with SEED) and save
@PiotrKrosniak
PiotrKrosniak / 2_Web_Scraping_From_W3Schools.py
Created December 2, 2022 08:17 — forked from mkx775/2_Web_Scraping_From_W3Schools.py
Web scraping from w3schools - A gist by @mkx775
# Web scraping from w3schools
from urllib.request import urlopen as get
from bs4 import BeautifulSoup
b_url = 'https://www.w3schools.com/python/'
n_url, s_url = 'python_intro.asp', 'python_exam.asp'
page_count = 0
def start(base_url, next_url, stop_url):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#Read list of RSS feeds from CSV files and save outpoot in another CSV
import feedparser
import csv
import jsonpickle
writer = csv.writer(open('items.csv', 'w'))
reader = csv.reader(open('feeds.csv', 'r'))
next(reader) # column headings
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os
bot = ChatBot('Bot')
bot.set_trainer(ListTrainer)
for files in os.listdir('C:/Users/pkrosniak/PycharmProjects/chatbot/chatterbot-corpus-master/chatterbot_corpus/data/english/'):
data = open('C:/Users/pkrosniak/PycharmProjects/chatbot/chatterbot-corpus-master/chatterbot_corpus/data/english/' + files ,'r'). readlines()
import tweepy
from time import sleep
from credentials import *
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
user_profile = api.user_timeline(screen_name = 'NAME', count = 1, include_rts = False)
# Import Tweepy, sleep, credentials.py
import tweepy
from time import sleep
from credentials import *
# Access and authorize our Twitter credentials from credentials.py
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
import tweepy
import pandas as pd
from datetime import datetime
def lookup_user_list(user_id_list, api):
full_users = []
users_count = len(user_id_list)
try:
for i in range((users_count // 100) + 1):
print i
# Import Tweepy, sleep, credentials.py
import tweepy
from time import sleep
from credentials import *
# Access and authorize our Twitter credentials from credentials.py
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
from twitter import Twitter, OAuth, TwitterHTTPError
import time
# enter the corresponding information from your Twitter application:
consumer_key = '' # keep the quotes, replace this with your consumer key
consumer_secret = '' # keep the quotes, replace this with your consumer secret key
access_token_key = '' # keep the quotes, replace this with your access token
access_token_secret = '' # keep the quotes, replace this with your access token secret
t = Twitter(auth=OAuth(access_token_key, access_token_secret,