Read .pbix file content through C# or java - datasource

I am when trying to use java / c# or any other programming language to modify .pbix file which generated from Microsoft Power BI. Is there any dll provided by POWER BI or how can i read the content through program. I just want to get and update the datasource directory. Please help.
Thanks.

I don't think it's possible, and even if it is, the solution is likely inelegant.
Even if you managed to do this, you would need to open your PBIX file in the PBI Desktop to refresh your data.
Are you doing this because you have many queries and it's inconvenient to change data source string (folder name) of all of them? There is a way to keep your connection string in a single variable as described here.
I don't know your exact setup, but looking at your question, lets say you have sets of files in different folders and you want to change the folder in one step.
To use the approach from the link above but with file input, you need to do the following:
If it's a new report, import your files as usual
Create new query: "New Source"->"Blank Query"
You will see "Query1" and an empty text box, enter the folder name, for example "C:\". Rename this query to "Folder".
Go to your imported file in the query editor, "test1" in my example. In query settings on the right, select source.
Change the filename by substituting the folder with your "Folder" query, for example:
...File.Contents("C:\test1.csv"),...
...File.Contents(Folder & "test1.csv"),...
Repeat for all imported files, then "Close & Apply".
Now whenever you need to change the folder with your files, edit your "Folder" value and "Refresh".

Related

How to Create a Program Which Searches for Values from a .txt or any Text Document in Specific Folders

I am relatively new to programming and want to create a program which can solve a problem that I frequently have.
So here's the background to my short story: I was on a website which hosted many files (We're talking about around 500-1000 small files). I was then like," Oh sweet! I want to have all these things in my hard drive so I know that I have access to them... but am probably not going to use them either way". I proceeded to download all 500-1000 files on that site, but encountered a problem when I looked at the properties of my destination file. Let's say that out of 500 on the site, my computer only had 499 files. Just my luck. I wanted to know what was that one pesky file that slipped right by me and download that file specifically. What I didn't want to do was to delete all the files and then try my luck once more in downloading all the files from the website. On the site, there was no indication of what all files I downloaded, so I was completely in the blue. I could go in Ctrl+C each item, then Ctrl+V into the file manager search bar, but that would be tedious to repeat that 500 times.
Now, what I want to do: I wanted to go ahead and take all of the file names from the website (The file name that I downloaded and the file name that was in my drive are the same), put them all in a simple .txt document or something (The website has multiple unwanted text alongside the text I need, such as:
. If this is not possible to extract the text from the site like this, then I am ok with manually entering the names via copy paste). Then I want the computer to take these values in the document and then search for it in a specific folder path (Note: the actual files are in subfolders within the root folder I want to choose, so the program has to be able to search within multiple folders of the root). Then I want the computer to know if the value in the document, is present as a file. If the file doesn't exist, then I want that value/those values in the document to be displayed as the output. I want this cycle to repeat until all the values have been gone through. The output should list the values that were not present.
Conclusion: You probably now get at what I am trying to do, if you don't, tell me what I need to elaborate on. I really don't care how this program is made (what language or software), I just want something that works... but myself don't know how to create.
Thanks for reading and any response is appreciated!
Dhanwanth P :)
Here's a solution in Python in case you would like to explore...
Similar to what you described, all files from the website are listed in an Excel file 'website_files.xlsx'
And all files are saved in a folder 'downloaded_wav'. The script will work regardless the files are saved in the root directory or sub-folders.
Then I run below Python script to look for the missing file:
import pandas as pd
import os
path_folder = 'C:\\Users\\Admin\\Downloads\\downloaded_wav'
downloaded_files = []
d,m = 0,0
for path_name, subfolders, files in os.walk(path_folder): #include all subfolders
for file in files:
d+=1
downloaded_files.append(file)
df = pd.read_excel('website_files.xlsx')
for file in df.values:
if file not in downloaded_files:
print('MISSING', file)
m+=1
print(len(df), 'files on website')
print(d, 'files downloaded')
print(m, 'missing file(s) found')
Output:
MISSING ['OLIVER_snare_disco_mixready_hybrid.wav']
3 files on website
2 files downloaded
1 missing file(s) found
No worries; I found a solution by myself using Excel (God, it's powerful!).
Basically, I copied and pasted my values from the website, then used a filter to show the values only with .wav. Then I used a Power Query from the folder to get me a list of all names of files in a folder. Finally, I went ahead and compared the two using a formula:
=IF(COUNTIF(B:B,D,"OK","MISSING")
If you need more elaboration, I'd be happy to help, just reply to this. There might be an easier way, but I personally liked the straight-forwardness of this. You only need Microsoft excel!
EDIT:
For me, I used these two videos which go over the power query and countif function:
How to Get the List of File Names in a Folder in Excel (without VBA): https://www.youtube.com/watch?v=OSCPVBWOqwc
How to Compare Two Excel Sheets (and find the differences): https://www.youtube.com/watch?v=8Ou_wfzcKKk
In my case, I made my sheet look like this:

Programmatically set default column values based on folder in SharePoint Online

I'm working on enhancing metadata in our SharePoint online (O365) environment. Since a portion of my user base is used to foldering (explorer style), I've started using default column values to automatically set values on any files added to that specific folder (we have content organized categorically by folder currently). An example is our HR documents library - we have separate folders for recruiting, payroll, personnel files, etc. that automatically categorize files added to that folder with the same categories (recruiting, payroll, personnel, etc.). This supports both "search" and "click" users and makes adoption WAY easier while getting important metadata.
I want to implement this in a larger, more dynamic fashion, so manually setting default column values on each folder is not going to be scalable.
How can I reference the top level folder within the library (or even the current folder) for each newly added file and populate the "category" field for that new file with that folder name? I can do some very basic C# or Java code copy/paste, but bonus points for non-coding solutions =)
This problem can be solved through no coding.You can use the workflow to implement this by SharePoint Designer.
Create different view for different function team, and then use the view filter to show the document.
If you upload a file, use the workflow to set the metadata of the file. There are some known limitations: if you upload multiple files at the same time, the metadata for the file maybe does not work well; or if you upload a folder, the meta will not work for it and the file in the folder may not be set to right metadata.
I was actually able to use MS Flow to accomplish this in a pretty simple and straightforward fashion without managing custom views per team. The concept at a high level was:
(Trigger) When a new document is created in a folder in the library
Get the link of the parent folder of the newly added document
Create a variable (or just code it out in the Flow step) to parse out the name of the parent folder from the parent folder link (should be all text to the right of the last "/")
Set the category field as the variable
I'm sure that you could do the same right in a SharePoint designer workflow, but I prefer flow due to the visual aspect of it and being far easier to troubleshoot.

Automatically import new csv file data into a "Database" Excel workbook

My situation:
At a competition, we will have 6 "scorers" each using a separate android tablet. For every game (there will probably be 70 or 80 throughout the tournament), each person will score accordingly on a custom app that will create a .csv file. (To be clear, each match will result in 6 separate, 1 row, csv files.) The format of the data will be the same from game to game, and from scorer to scorer. I can have control over the names of these files such as "[Scorer#]_[Match###].csv". These tablets will all be connected to a central computer via USB.
What I would like to do:
I would like to be able to have the data from all of those files automatically populate a "database" table on a single sheet. If possible, I would like a folder to act as a "watch folder" of sorts, where, as a new file shows up in a folder, that data is automatically ingested into the table. If that is not possible, I would be happy with a single function I could run to check for new data after each game ended.
I had considered possibly trying to use power query, but wasn't sure if that could lead me to a usable solution.
Any suggestions would be greatly appreciated!
(and I apologize if anything is unclear. I'm happy to clear up any confusion)
Power Query is a good fit in that scenario. You can set up a query that loads all files in a specific folder and appends the contents. Refresh the query when new files have been added to the folder.
For detailed instructions how to set up such a query, take a look here:
http://excelunplugged.com/2015/02/10/get-data-from-folder-in-power-query/

VB.NET Create downloadable resource

I've become stuck at this hurdle. I'm trying to create a database that clients fill in, however the client can set different database paths to view different information in the program. I want to create template databases so should they wish to create a new database it will work with the SQL queries the program uses.
I'm trying to save the templates in to the program so that when a button is clicked, the template file is "downloaded" (copied) to the clients desktop.
Is this even possible?
Thanks
You can open the Resources page of the project properties and add any existing file, including a SQL Server MDF data file. At run time, you can get the data of the file from the appropriate property of My.Resources. The type of the data depends on the type of the file. I'd expect that an MDF file would come back as a Byte array, which you can then write to a file or whatever.
That said, you don't want to make your EXE too big by embedding several sizeable data files in it. You might be better off just using loose files in a subfolder or, if you're determined to use resources, create a satellite assembly, i.e. a DLL that contains just resources.

Import Access Database into VB.NET2010 Application and then refer to it locally?

I am writing a program for a class and it needs to read/write to an Access 2007 database. Right now I am referring to it's absolute path when I use it in connection strings, something like:
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Me\Documents\Visual Studio\Projects\Project1\Database.accdb")
This is going to be a problem when I turn it in obviously, because the professor isn't going to have the same path. So I want to somehow include it into my project and then refer to it with a relative path or something so that it will work on his machine. When I imported it through the Data Sources it had an option at the end to copy the database into the project which I agreed to. It put the Database where all of the source files are on my computer, so I tried using Application.StartupPath(), but that refers to the folder in bin\Debug when you run the program from Visual Studio (this is not where it put the database). Help!
I feel like this is a bit "hacky" but, if you add it to your solution you can right-click and hit properties. Then make Copy to Output Directory = Copy always to have it always copied to your output directory. Then you can use Application.StartupPath() like you wanted.