If say name the fields like so: PointName, XCoord, YCoord
Easiest to use InlineQuerier with the following SQL string by feeding it the CSV table as a table called "Points" like so:
SELECT A.PointName||'_'||B.PointName AS LineName, A.XCoord, A.YCoord, 1 AS OrderingTerm
FROM Points A, Points B
WHERE A.PointName<B.PointName
UNION ALL SELECT A.PointName||'_'||B.PointName AS LineName, B.XCoord, B.YCoord, 2 AS OrderingTerm
FROM Points A, Points B
WHERE A.PointName<B.PointName ORDER BY LineName, OrderingTerm
I don't know why the Code formatter puts a "5." in the above bit of the post, but ignore that bit.
Thanks so much for the help. I've never used InlineQuerier before. I think it's working but I have to test further.
I've done some more testing with InlineQuerier and the SQL string listed above by bwn. When I click "Run" on the SQL Query dialog, I get a message saying "Database not specified, format and dataset unspecified, Please specify the format and data set required for the query". I'm not experienced with the InlineQuerier so I think I have to take a different approach. I thought using lists might help. Thanks for your help.
I've done some more testing with InlineQuerier and the SQL string listed above by bwn. When I click "Run" on the SQL Query dialog, I get a message saying "Database not specified, format and dataset unspecified, Please specify the format and data set required for the query". I'm not experienced with the InlineQuerier so I think I have to take a different approach. I thought using lists might help. Thanks for your help.
@mdumka That's normal to get that message in InlineQuerier. It reuses the same SQL input dialog as other SQL based transformers, but as it is a temporary database that only gets created when the Transformer is run, you can't test the SQL unless you run the Transfomer, say with Feature Caching turned on and analysing the Partial Results on the output port(s).
So the error message is matter-of-factly telling you that it can't test the statement because there is not yet any database to test it on. As blank SQLite databases are extremely small and low-overhead, this is not a huge problem to test it by running the Transformer itself, or you can similarly use a FeatureWriter to push the table out to a parallel SQLite database for testing purposes to do your SQL text string fine-tuning inside this (There are plenty of SQLite GUIs available online, although I like to use the SpatiaLite GUI supplied by SpatiaLite's author/developer: Alessandro Furieri, since it nicely covers off both my SQLite and SpatiaLite development/testing needs)
I've done some more testing with InlineQuerier and the SQL string listed above by bwn. When I click "Run" on the SQL Query dialog, I get a message saying "Database not specified, format and dataset unspecified, Please specify the format and data set required for the query". I'm not experienced with the InlineQuerier so I think I have to take a different approach. I thought using lists might help. Thanks for your help.
@mdumka ....forgot to add:
- Suggest use the updated SQL text I've amended the original Answer with. I hadn't yet put the Ordering bit into the post as needed to test that a little further with how that works with Compound/Union queries, so not sure if you got the older or newer version of what posted below.
- In InlineQuerier, the way to test the syntax of the statement is instead to run the Transformer and review FME's Translation Log window (as above, can't test using the "Run" button in the SQL input windows). Any syntax errors will get reported by the SQLite engine back through this window with the same error messages you would see if you were natively running the SQL inside the database engine itself.
@bwn, thanks so much for the explanation. I appreciate you detailing how InlineQuerier works. I understand your comments about not being able to test the SQL because the temporary database is only created when InlineQuerier is run. I clicked on "Run" on the SQL Query dialog because at first the OK button was greyed out, and so I thought I had to test first. Later I clicked on the greyed out OK button and it allowed me to proceed. I am using the updated SQL including the OrderingTerm. I found that in the csv Reader I must set the FeatureTypeName to "From File Name" (not the default "From Format Name") or else the InlineQuerier cannot find the csv file. I got the results I was looking for using the SQL you provided. Thanks again.