HG-map 2
GIS, dev & data

Menu

  • Accueil
  • Blog
  • Tutos
  • Astuces
  • Exercices
  • À propos de moi

Privé

  • Pandas

Tests Fabrik

  • Formulaire devis
  • Utilisateurs

Connexion

  • Mot de passe perdu ?
  • Identifiant perdu ?

Fix unwanted line breaks with Notepad and some regex

Détails
Mis à jour : 19 Juillet 2020
Clics : 3116
  • Database
  • SQL
  • Data mining
  • Web scraping
  • Notepad
  • Regex

When you have to import files as text, csv, etc ... into an SQL database, non-desired line breaks (often from notes fields, text boxes,  <BR> tags, tabs, or other misinterpreted HTML ...) are very painful. It may fail your import, or be a waste of time. Exploring one's file with Notepad is sometimes necessary.

Complete 4-step correction

How to effectively manage these line breaks?

In this standard example, we want to identify and fix lines that do not start with a double quote (caused by line breaks) within a file where healthy lines start with a double quote.

Lire la suite : Fix unwanted line breaks with Notepad and some regex

Django REST API

Détails
Mis à jour : 13 Avril 2020
Clics : 16133
  • Database
  • Django
  • API

Django REST API 2Here some tips about Django REST Framework (DRF) with Django 3.

Official website

Quick install

[code]> pip install djangorestframework[/code]

Then in settings.py:

[code]INSTALLED_APPS = [
...
'rest_framework',
][/code]

Let's go!

Lire la suite : Django REST API

Mémo Django/GeoDjango/Python

Détails
Mis à jour : 21 Mars 2020
Clics : 7417
  • SIG
  • Postgres
  • Django
  • Python
  • Framework
  • GeoDjango
Liste de commandes non-exhaustive bien sûr, et surtout propre à mon usage personnel (sous Windows). Ce mémo est lié à l'article À la découverte de Django et GeoDjango.

Créer un projet Django (un site)

Sous Windows :

python -m django startproject mon_projet

Sous Linux :

django-admin startproject mon_projet

Sous Linux mais avec des versions anciennes, parfois :

django-admin.py startproject mon_projet

Créer une app Django (une fonctionnalité du site)

Placez-vous dans votre projet, changez le nom d'app souhaité, puis :

python manage.py startapp mon_appli

À chaque fois qu'il faut se placer dans le répertoire de votre projet Django, c'est pour utiliser le fichier manage.py, qui permet d'appeler Python directement à partir de votre projet personnel, pourtant situé hors de l'environnement virtuel.

Lire la suite : Mémo Django/GeoDjango/Python

Prise en main d'un entrepôt de données sous Talend

Détails
Mis à jour : 25 Novembre 2019
Clics : 81532
  • Database
  • MySQL
  • Postgres
  • SQL
  • ETL
  • Big data
  • Talend

Talend est une suite logicielle ETL, dont l'une des briques existe sous licence libre et gratuite : Talend Open Studio for Data Integration (TOS), dédiée à l'intégration et à la manipulation de sources de données hétérogènes. 

Téléchargez l'outil depuis la page officielle et installez-le sur votre machine. Il s'agit de dézipper le fichier fourni et de le placer près de vos programmes. Il contient deux exécutables (.exe), selon la binarité de votre machine, dont vous pouvez créer un raccourci.

N'hésitez pas à tester les deux exécutables en 32 ou 64 bits si besoin (incohérences constatées sur certaines machines sous Windows, mais sans problème fonctionnel).Figure d'un Data Warehouse Architecture (documentation Oracle, 2018)

Pour fonctionner, Talend a besoin d'une version récente de Java.

Ce tutoriel d'initiation suppose que soyez déjà familier avec les SGBD MySQL et/ou Postgres, et que vous en disposiez.

Les images de cet article sont cliquables et affichent des informations contextuelles supplémentaires.

Lire la suite : Prise en main d'un entrepôt de données sous Talend

À la découverte de Django et GeoDjango

Détails
Mis à jour : 28 Octobre 2019
Clics : 57158
  • SIG
  • Postgres
  • Django
  • Python
  • Framework
  • GeoDjango

Dans l'éternelle quête d'un système simple et performant pour mettre en place un système d'édition de données spatiales via un navigateur web, de façon sécurisée et sur une base Postgres, il faut nous confronter au framework Django.

Cet article est une vulgarisation/fusion des deux tutoriels officels Django et GeoDjango. Ces derniers sont bien plus détaillés et vous les trouverez ici : 

  • Tutoriel officiel Django : https://docs.djangoproject.com/fr/1.9/intro/tutorial01/
  • Tutoriel officiel GeoDjango : https://docs.djangoproject.com/fr/1.9/ref/contrib/gis/tutorial/

Le tuto officiel Django se base sur les toutes dernières versions des outils, et sur Linux. En fonction de sa machine locale ou des serveurs web à notre disposition, il peut y avoir des différences. La syntaxe de certaines lignes de commande Django ou Python peuvent changer, ainsi que la façon d'appeler vos apps ou vos importations.

D'autre part faire ses 1ers pas dans GeoDjango nécessite de s'être d'abord familiarisé à Django. On n'utilise pas ce module additionnel sans le framework complet.

Je vais donc tenter de clarifier tout cela, ne serait-ce qu'à mes yeux, et en allant rapidement vers les fontionnalités les plus basiques de GeoDjango. Au terme de cet article, nous aurons un système de CRUD sur de la donnée spatiale, en points, lignes et polygones, avec un fond OpenStreetMap, le tout accessible sur authentification.

Lire la suite : À la découverte de Django et GeoDjango

Manage a smart thesaurus from free keywords

Détails
Mis à jour : 3 Octobre 2019
Clics : 3053
  • Database
  • SQL
  • Digital marketing
  • Vimeo

Recently I wanted to add a dynamic thesaurus in a medical videos information system. Videos are hosted at Vimeo, sometimes with access rights. End user must go through the system to view all the videos.

We would that end users to be able to navigate from one video to another according to suggestions from common keywords, visibles or not. In order to increase the average session duration on the website.

Administrators are medical professionals, they add scientific content with references potentially very detailed, and impossible to guess exhaustively.

So to organize the videos it was necessary to allow administrators to enter free keywords, like tags, in a simple text field. Nothing incredible so far example:

This is already enough to enrich user searches. But how to link the videos between them? Gracefully if possible.

Keywords should feed a formatted thesaurus, which can be used with SQL. Otherwise you will face to limitations of using, or need to multiply queries just to display few links.

Lire la suite : Manage a smart thesaurus from free keywords

Recover names from anonymous email addresses avoiding errors

Détails
Mis à jour : 19 Mars 2019
Clics : 2682
  • Database
  • SQL
  • Emailing
  • Newsletter
  • Web scraping
  • Digital marketing

Many tools can retrieve names from anonymous emails. But to get something clean, avoid errors and keep a custom default value for generic emails, better to do it yourself.

First, description of the problem.

Tag name

Here we concatenate salutation, first and last names from a table called users, in a tag called name. This in order to personalize newsletters, example:

Salutation First name Last name HTML View in mailbox and browser
Mr Edward Osborne Wilson
[code]Dear [name][/code]
Dear Mr Edward Osborne Wilson

OK good. But sometimes we have not all salutation, first and last names. And may we get a strange value even with all 3 fields concatenated:

Lire la suite : Recover names from anonymous email addresses avoiding errors

Page 4 sur 5

  • 1
  • 2
  • 3
  • 4
  • 5