Skip to content

Instantly share code, notes, and snippets.

@pietrocolombo
pietrocolombo / parsing_geolife_dataset.r
Last active December 11, 2020 10:25
parsing geolife dataset to csv with label
# data-set
# http://research.microsoft.com/en-us/projects/geolife/
# script for reading .plt file and label file
# assigns the associated label to each point
# each folder represents a user, we only consider users who have the labels.txt file
# I take the path of each folder
dirs_perc = list.dirs("../Geolife Trajectories 1.3/Data", recursive = FALSE)
# I take the name of each folder which identifies me as the user
@pietrocolombo
pietrocolombo / add_feature_consistency.r
Created December 11, 2020 10:58
consistency check and add new features
# let's add information to our dataset
# function to transform angles deg into radians
deg2rad <- function(deg) {(deg * pi) / (180)}
if(!require(geosphere)){
install.packages("geosphere")
library("geosphere")
}
# from the n lines that identify me a path I get one line per path
# I load the csv that the add_feature_consistency.r script generated for me
perc_csv <- "dataset_with_add_features.csv"
dati <- read.csv(perc_csv, header = TRUE, sep =",", quote = "\"", dec = ".")
# we remove the file that generates this script
file.remove("dataset_compresso.csv")
# query to OpenStreetMap or bing to obtain information on the state, city,
# region both on the starting and ending point of each route
if(!require(revgeo)){
install.packages("revgeo")
library("revgeo")
}
# I read the csv generated by the script compress_database.r
if(!require(corrplot)){
install.packages("corrplot")
library("corrplot")
}
if(!require(RGraphics)){
install.packages("RGraphics")
library("RGraphics")
}
if(!require(grid)){
install.packages("grid")
import logging
import logging.handlers
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO, filename='log.log')
logger = logging.getLogger(__name__)
@pietrocolombo
pietrocolombo / delete_duplicate_file.py
Last active November 24, 2024 07:50 — forked from vinovator/checkDuplicates.py
Python script to merge or delete duplicate files from a folder
# delete_duplicate_file.py
# Python 3.8.6
"""
Given a folder, walk through all files within the folder and subfolders
and delete all file that are duplicates so you have only one copy of every file
The md5 checcksum for each file will determine the duplicates
"""
import os
# let's add information to our dataset
start_time <- Sys.time()
# function to transform angles deg into radians
deg2rad <- function(deg) {(deg * pi) / (180)}
if(!require(geosphere)){
install.packages("geosphere")
library("geosphere")
}
# let's add information to our dataset
start_time <- Sys.time()
# function to transform angles deg into radians
deg2rad <- function(deg) {(deg * pi) / (180)}
if(!require(geosphere)){
install.packages("geosphere")
library("geosphere")
}
@pietrocolombo
pietrocolombo / list.c
Last active April 14, 2021 19:04
functions to manage lists
#include <stdio.h>
#include <stdlib.h>
typedef struct listas {
int info;
struct listas * next;
} list_t;
int listlen (list_t *);
list_t * listaddhead (list_t *, int);