Hi,
I'm looking for a way to extract data from a table by means of an API.
I would like to just access the zip codes, "indicator codes" (like "Member/Non Member") from the "Members Table".
With that data I would Plot a map.
What I do now is extracting this fields as .csv and then go to a plot application.
So if I could skip the extracting step ..... that would be great.
Is this possible or does this already exists?
Ron
Extracting data by means of an API
Re: Extracting data by means of an API
Hi Ron,
actually you can write a small php script that extracts your data and either save it as a csv file, or just echo it out.
Otherwise the is the API https://github.com/rafinhacarneiro/appgini-api that you may try.
actually you can write a small php script that extracts your data and either save it as a csv file, or just echo it out.
Otherwise the is the API https://github.com/rafinhacarneiro/appgini-api that you may try.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Extracting data by means of an API
If your plot application can import json data instead of csv, this code can help you.
Create a file called export.php inside your hooks folder
By accessing the export.php it will generate the data you need in json format
Otherwise you can try this code that will output a csv data:
PS. Change the query to reflect your need.
Create a file called export.php inside your hooks folder
Code: Select all
<?php
include("../lib.php");
$query = sql("SELECT * FROM members", $eo);
$json_array = array();
while($row = mysqli_fetch_assoc($query))
{
$data[] = $row;
}
echo(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK));
?>
Otherwise you can try this code that will output a csv data:
Code: Select all
<?php
include("../lib.php");
$query = sql("SELECT * FROM members", $eo);
$json_array = array();
while($row = mysqli_fetch_assoc($query))
{
$data[] = $row;
}
$jsondata = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
$jsonans = json_decode($jsondata, true);
$file_pointer = fopen('php://output', 'w');
foreach($jsonans as $i){
fputcsv($file_pointer, $i);
}
fclose($file_pointer);
?>
Re: Extracting data by means of an API
Hi PBöttcher and Alisson,
Thans you both to pointing to some solutions.
I’ll have werk to do
Ron
Thans you both to pointing to some solutions.
I’ll have werk to do
Ron
Re: Extracting data by means of an API
Two months later
Well, I've found someone within my volunteers club, he made a nice, secured, interactive plot for me.
Thank you for pointing to the solution.
A screen crab from the result
Ron
Well, I've found someone within my volunteers club, he made a nice, secured, interactive plot for me.
Thank you for pointing to the solution.
A screen crab from the result
Ron
- Attachments
-
- Heiloo-Energie_map.JPG (106.54 KiB) Viewed 2072 times