Forum Discussion

cxb's avatar
cxb
New Member
7 years ago

Custom connector for proprietary file type

We'd like Power BI Desktop to understand a custom file format and for users to be able to select a file of that type and have Power BI Desktop open it (generating probably multiple tables). Were I'm currently at with this is trying to create a custom connector for this and coming up against a number of issues. So a general question - is a custom connector the right way to go, or is there some other way to open a particular file type and have Power BI apply some Power/M query to extract the relevant data (bearing in mind the ideal is for the user to be able to select a file and have the data appear without delving into any data manipulation themselves)?

 

One of the issues I'm getting is with credentials - relevant section of code below. Accessing a test file using Visual Studio to debug (e.g. PQExtension1.Contents("\\path\to\test\file")) requests credentials when first running for Data Source Kind PQExtension1 (I select 'Windows' and Set Credential), but then requests credentials again when running subsequently, this time for Data Source Kind File. How to reuse the credentials previously entered?

section PQExtension1;

[DataSource.Kind="PQExtension1", Publish="PQExtension1.Publish"]
shared PQExtension1.Contents = (path as text) =>
    let
        Source = Xml.Tables(File.Contents(path)),
        pkg = Source{0}[pkg],
        pkgNav = GetLevelAsTable(pkg) //not getting as far as this
    in
        pkgNav;

PQExtension1 = [
    Authentication = [
        Windows = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];
...

So - is there a better way than custom connector and if not, can I reuse those credentials?

 

Many thanks

 

Craig

3 Replies

    • cxb's avatar
      cxb
      New Member

      Thanks Dale (many thanks for the lot of tests!). So no to the custom connector route. Is there any means of using a particular M/power query to load a file with a specific extension though (or something similar)? E.g. .xyz files open (get pre-processed, effectively) with XYZ.pq.