Recreate Titan Graph with Gremlin commands - titan

I'm familiar with using graph.io(graphson()).writeGraph("/tmp/graph.json") or graph.io(graphml()).writeGraph("/tmp/graph.xml") to create json or xml files which can later be used to repopulate a Titan Graph.
Is there a way to generate a series of gremlin graph statements in the same way that can be played back to recreate a graph?
e.g.
graph.addVertex(...)
graph.addEdge(...)

No. There is nothing built into TinkerPop (or Titan) that will generate lines of Java code. You would have to write your own custom code to concatenate together such output.

Related

Is it possible to change the datasource of a twb file using tableauserverclient?

Use Case:
Given a Template.twb that uses Template.hyper I want to create Copy1.hyper and Copy2.hyper that are used in Dashboard1.twb and Dashboard2.twb using automation and the Tableau API.
I've broken this down into three steps, but I can only do the first two currently.
Write the hyper files using the Hyper API and publish to Server
using
Create and publish Dashboard1.twb and Dashboard2.twb that still use Template.hyper as a datasource.
Change datasource of Dashboard1.twb to Copy1.hyper.
I think this is done using workbooks.update_connection, but I haven't gotten it to work or found an example online.
I'm a python novice and mostly using the python scripts made available in the Hyper API and Tablea Server Client to create and publish respectively.
Is this possible?
I can change the datasource by hand in tableau desktop, but we want this automated.
I was thinking I could just append all the data and filter on some unique string generated by each query, but this seems like it would get unwieldy very fast.

Oracle hierarchial queries

I am trying to pull out all the hierarchy values for a particular segment in Oracle Apps(referring tables applsys.fnd_flex_Value_norm_hierarchy & applsys.fnd_flex_values). I want a tree like display starting from the top parent and going down until the last descendant) something like this:
I have been able to pull the data with repeated parents across each lines and currently formatting this manually in excel, but am sure there is a way to do this using sql itself but not able to do it. Please note I have already written a sql which gives me data as follows.
Any suggestions would be really helpful.
We have a treewalk SQL for this data in our Blitz Report library here: https://www.enginatics.com/reports/fnd-flex-value-hierarchy/
The output looks like this:
https://www.enginatics.com/example/fnd-flex-value-hierarchy/

Can Tableau return non-UI results programmatically?

Tableau is an excellent tool for visualizing data. However, it is designed to be the final stop in a data (ETL) pipeline.
My Tableau workbook uses a bunch of Table Calcs to generate a list of "recommended orders". Rather than view these, I want to automate and execute them. This would make Tableau the engine of a quasi-ML process.
In other words, I would like to make Tableau a part of my ETL pipeline and send data to another tier. How can I write a back-end program that executes my Tableau workbook and receives a results dataset?
See the end of this article for example data I want to automate:
http://robm26.blogspot.com/2015/10/keep-your-factory-humming-with-tableau.html
Any ideas?
You're not not going to like the answer I'm going to give you -- "Don't do this".
Tableau isn't meant to be a task in a larger ETL pipeline and the reason you're having problems making it behave the way you want is it's not meant to be done.
Above and beyond the fact that you've figured out how to get a result that you want in Tableau ("the work is done"), Tableau isn't offering you any real value in the scenario you're describing. Use a tool (like Alteryx) that is really purpose built for this sort of work.
The above answer is correct that tabcmd is the way to pull it out. We use a function in python to generate the tabcmd requests so that they can be batched.
import subprocess
def runTabCmd(cmd):
# run tableau command and display the output
print cmd
if run_tabcmd == 'yes':
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
print line
You probably already knew that, but for us it was a way to completely automate the pulling and loading into another python package like scikit-learn for a streamlined ML solution
I'm editing this answer to agree with Russell's answer. Tableau is not an ETL tool and should not be used as such. If you absolutely have to do something, you can use what I provided. Otherwise, the best practice is to use a tool designed for the job.
You can easily use tabcmd to get the results of a view in CSV, which can be used later in your ETL process. If you need to automate it, you can write a script and execute it with a cron job. I, myself, have a few views that are exported to CSV and used later in my ETL stream to feed our CRM.
Just remember to create the view exactly as you want it to be exported to CSV - usually including the order of the fields. Another tip is that I don't let it use the default "Measure Names" and "Measure Values" - to make sure everything is good on my CSV, I have the fields added manually in the row/columns section.

Exporting NetLogo data to graph with nodes and edges

I have created some links between agents (turtles) in NetLogo. This links will change at each time step. My aim is to export this data (i.e., turtles and links b/w them) to graph with vertices (turtles) edges (links), which can be given as input to Gephi. Is it possible to see the changes which occurs in netlogo in the graph when it is linked with Gephi. Can someone help me out. Thanks.
To export your network data in a format usable by Gephi, I would suggest using the nw:save-graphml primitive from NetLogo's NW Extension. This will give produce a file in the GraphML file format, which Gephi can read.
I guess you could re-save your network at each time step and overwrite your file, but I'm not sure if Gephi can display your changes dynamically. And depending on the size of your network, it might be slow.
Are you trying to use Gephi to see how the network changes over time, in a changing network that is generated by NetLogo? That's what #NicolasPayette's answer suggests, so I'll make the same assumption.
Gephi can display "dynamic graphs", i.e. networks that change over time. My understanding is that are two file formats that allow Gephi to import dynamic graphs: GEXF, and a special CSV (comma-separated) format that Gephi calls "Spreadsheet". Nicolas mentioned GraphML, which is a very nice network data format, but it doesn't handle dynamic graphs. And as far as I know, NetLogo doesn't generate GEXF or Gephi's "Spreadsheet" format.
However, the Gephi Spreadsheet format is very simple, and it would not be difficult to write a NetLogo procedure that would write a file in that format. This procedure would write new rows to the "Spreadsheet" CSV file on each NetLogo tick. Then Gephi could read in the file, and you'd be able to move back and forth in time, seeing how the graph changes. (You might need to use a bit of trial and error to figure out how to write Spreadsheet files based on the description on the Gephi site.)
Another option would be to display the evolving graph online using the graphstream protocol. Plugins for NetLogo as well as for gephi provide support for this.

Openstreetmap Xapi filters

Is there anyway to filter the results returned using xapi so that I don't have a ton of results to work through? I thought something like [filter=tag] might only show tags but I can't seem to find any documentation saying this is possible.
Thanks
(1) The standard way of using XAPI lets you filter to retrieve only objects tagged with a certain tag, for example just to get pubs you'd use:
http://jxapi.osm.rambler.ru/xapi/api/0.6/*[amenity=pub]
(2) If you want to filter an OSM file after you've downloaded it (e.g. to remove certain tags), Osmosis is a command-line tool that can do various types of filtering.
(3) If you want to filter an OSM file into some other format (i.e. you're not interested in having an OSM-format XML file at the end) you could use XSLT. Here is an XSLT I made which extracts a small number of pub parameters from an OSM file to CSV.