(Instagram)-Locationprojekt, Hashtagcloudanalysen nach Orten (Berlin-Datenbank)

Heute fand ich Gelegenheit, das Projekt in einer ersten Version zu compilieren. Dieses beinhaltet auch die Funktion der Auflistung von Tagclouds nach Locations inkl. deren Aufsummierung.

Folgende Dateien liefern erste Interpretationsgrundlagen zu den Locationbewertungen.

Inhaltsschema:
Spalte (1) -> Nummer
Spalte (2) -> Tagcloud
Spalte (3) -> Location
Spalte (4) -> Location-ID
Spalte (5) -> Summe Tagcloud, Vorkommen der Tagcloud in der Location

Beispiele.
Die nachfolgenden Datensätze basieren auf die Query „like ‚%suchwort%'“ und erfragen die Ergebnisse auf Substringebene.

(1) Substring: „working“: working_locsumm
(2) Substring: „work“: work_locsumm
(3) Substring: „office“: office_locsumm
(4) Substring: „neukölln“: neukölln_locsumm
(5) Substring: „kunst“: kunst_locsumm
(6) Substring: „job“: job_locsumm
(7) Substring: „happy“: happy_locsumm
(8) Substring: „foodporn“: foodporn_locsumm
(9) Substring: „food“: food_locsumm
(10) Substring: „feiern“: feiern_locsumm
(11) Substring: „fashion“: fashion_locsumm
(12) Substring: „coworking“: coworking_locsumm
(13) Substring: „berlin“: berlin_locsumm
(14) Substring: „advokat“: advokat_locsumm

Datenexporte: Instagram-Locationprojekt, Teil (1)

(1) Locationrecherche nach Auflistung der aktiven Accounts

SELECT location, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) order by Anz_user DESC

Diese Abfrage listet alle Locations auf, wo mind. 2 Accounts Postings abgesetzt hatten.
Datei (Paris): loc_2

(2) Locationrecherche nach Auflistung der aktiven Accounts, Anpassung nach Locationtyp

SELECT location as Ort, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) AND (location like '%museum%') order by Anz_user DESC

Diese Abfrage listet alle Locations auf, wo mind. 2 Accounts Postings abgesetzt hatten und erlaubt die Feinprüfung auf Locationtyp.
Datei (Paris), Hotel: loc_2_hotel
Datei (Paris), Museum: loc_2_museum

(3) Location- und Accountauflistung nach Suchwort (Tagsubstring)
select location, tag, username from locations where tag like '%fashion%' group by username;

Diese Abfrage listet alle Locations und Accounts auf, welche etwas zu „Fashion“ gepostet hatten
Datei (Paris), „fashion“: paris_fashion

(4) Userauflistung nach Suchwort UND Mindestaufkommen in Bezug auf die Locationaufsummierung

SELECT username, numb from(
Select username, tag, count(location) as numb from locations GROUP BY username ) as my_table
WHERE (numb >= 2) and (tag like '%fashion%') order by numb DESC;

Diese Abfrage listet alle erfassten Accounts auf, welche an mind. 2 Locations aktiv etwas zu „Fashion“ schrieben.
Datei (Paris), Loc=2, „fashion“: user_tag_fashion_2

Spezial-SQLabfragen (Projekt: Instagramlocations), Stand: 14.07.2018

(1) Ausgabe der Usernames als Auflistung, mit Mindestanzahl in Bezug auf die Locations

SELECT username, numb from(
Select username, count(location) as numb from locations GROUP BY username ) as my_table
WHERE numb >= 2 order by numb DESC;

(2) Ausgabe der Usernames als Auflistung mit Mindestanzahl in Bezug auf die Locations UND Vorkommen eines Substrings in den Tagwolken

SELECT username, numb from(
Select username, tag, count(location) as numb from locations GROUP BY username ) as my_table
WHERE (numb >= 2) and (tag like '%fashion%') order by numb DESC;

(3) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen

SELECT location, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) order by Anz_user DESC

(4) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen UND Vorkommen eines Substrings in den Locations

SELECT location, Anz_user from(
Select location, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) AND (location like '%hotel%') order by Anz_user DESC;

(5) Ausgabe der Locations als Auflistung mit Mindestanzahl in Bezug auf die erfassten User_innen UND Vorkommen eines Substrings in den Locations UND Vorkommen eines Substrings in den Tagwolken

SELECT location, Anz_user from(
Select location, tag, count(username) as Anz_user from locations GROUP BY location ) as my_table
WHERE (Anz_user >= 2) AND (location like '%hotel%') AND (tag like '%fashion%') order by Anz_user DESC;

Basis-SQLabfragen (Projekt: Instagramlocations)

Notiz für mich:
Auflistung der Standardabfragen, ohne Anspruch auf Tiefenanalysen.

(1) Statistiken, „KPI“
select count(*), count(distinct(filter)), count(distinct(url)), count(distinct(tag)), count(distinct(location)), count(distinct(username)), count(distinct(erstellzeit)) from locations;

(2) Überblick, Auflistung der erfassten Accounts
select username from locations group by username;

(3) Auflistung der erfassten Accounts zzgl. Zusammenzählung der Beiträge der jeweiligen Accounts
select username, count(username) from locations group by username order by count(username) DESC

(4) Auflistung der erfassten Accounts zzgl. Zusammenzählung der Beiträge der jeweiligen Accounts + Zusammenzählung der Locations
select username, count(username), count(distinct(location)) from locations group by username order by count(distinct(location)) DESC;

(5) Auflistung der erfassten Locations zzgl. Zusammenzählung der Locations
select location, count(location) from locations group by location order by count(location) DESC;

(6) Auflistung der erfassten Locations zzgl. Zusammenzählung der Locations bei Vorkommen eines Tags / Zeichenketten
select location, count(location) from locations where tag like '%gucci%' group by location order by count(location) DESC

(7) Auflistung der erfassten Usernames zzgl. Zusammenzählung der Usernames bei Vorkommen eines Tags / Zeichenketten
select username, count(username) from locations where tag like '%fashion%' group by location order by count(username) DESC

(8) Auflistung der erfassten Tags zzgl. Zusammenzählung der Tags bei Vorkommen von zwei gesuchten Tags / Zeichenketten
select tag, count(tag) from locations where (tag like '%fashion%') and (tag like '%woman%') group by location order by count(tag) DESC;

Instagram – Zielgruppenerfassungen via Locations, Projektstart

Vor einigen Tagen entschied ich mich dazu, die Erfassungsfunktionen von CSV in SQLite zu wechseln.

Hierbei hat die entsprechende Datenbankdatei folgende Struktur (Einrichtungsprozedur):

procedure TForm1.LocationsMain1Click(Sender: TObject);
begin
with sql_befehle do
begin
clear;
lines.Add('drop table if exists locations;');
lines.Add('CREATE TABLE `locations` (');
lines.Add(' `id` integer primary key AUTOINCREMENT,');
lines.Add('`url` varchar(400),');
lines.Add('`tag` varchar(800),');
lines.Add('`likes` varchar(400),');
lines.Add('`comments` varchar(400),');
lines.Add('`erstellzeit` varchar(400),');
lines.Add('`post_id` varchar(1600),');
lines.Add('`username` varchar(400),');
lines.Add('`location` varchar(400),');
lines.Add('`filter` varchar(400),');
lines.Add('`pruefzeit` varchar(400)');
lines.Add(');');
lines.Add('vacuum;');
end;
fdquery3.ExecSQL(sql_befehle.text);
end;

Mit Datenbankwechsel wurde der Scraper so optimiert, dass an einem typischen Arbeitstag zwischen 1200 und 4500 Locations zu max. 1500 Einträge erfasst werden können. Erste Testläufe mit dem Raum Paris / Frankreich ergaben eine Ausbeute von ~400.000 Einträgen mit Aktivitäten von ~200.000 Accounts (Unique!).