Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic flat file datasource ?
Idefix
My Perl-Application has a powerful search functionality.
The result is a simple list of many items.
I would like to do some BIRT Reporting on the result items of this query
without doing this query again in BIRT.
How can I pass this items as Input to BIRT ?
My first idea was to use a csv File containing this items
as flat file datasource.
But how can I create a report with dynamic flat file ?
Can I pass the flat file name as parameter ?
Find more posts tagged with
Comments
mwilliams
Hi Idefix,
Can you explain more of what you're wanting to do? When you say dynamic flat file, do you mean that you'll actually be using different files to bring in the data? or will you be dynamically updating the data in the one file?
Idefix
Hi Michael,
thank you very much for your fast reply.
I think, in a multi user environment I will have to use different files to bring in the data.
Many users use the search functionality of the Perl Web Applikation.
The results of this search activities can be written into temporary csv-Files with the same structure but different content. The name of this file will be dynamic generated with timestamp and session id.
Now, my idea is to pass this files as flat file datasource to BIRT to do
further reporting on this query result items. Therefore I would have to pass the flat file name as report parameter to BIRT.
Or is there any other chance to do this ?
mwilliams
Idefix,
In you beforeOpen method of you dataSet, you should be able to set your flat file dynamically by setting the "queryText" property with the new file info. Look at the XML Source of your report and you'll see the "queryText" value is something like:
select "start_date", "record_count", "new_state" from Data.txt : {"start_date","start_date",STRING;"record_count","record_count",INT;"new_state","new_state",STRING}
As long as all of your columns are the same, you can set a new file by saying:
this.queryText = "select 'start_date', 'record_count', 'new_state' from " + param["filename"] + ": {'start_date','start_date',STRING;.....etc"
Let me know if this works for you.
Idefix
Hi Michael,
it sounds very good to me, but it does'nt work until now.
In words of Your example:
I tried to set hard coded a new flat file name by the beforeOpen method
this.queryText = "select 'start_date', 'record_count', 'new_state' from NewData.txt : {'start_date','start_date',STRING;.....etc"
This seamed to be ignored. Report data came from Data.txt as before.
The beforeOpen method
this.queryText = "select 'start_date', 'record_count', 'new_state' from " + param["filename"] + ": {'start_date','start_date',STRING;.....etc"
leads to javascript error "There are errors evaluating script ..."
I use BIRT Report Designer Version 2.3.2
mwilliams
Idefix,
If you put that exact string in that I put, it will not work. That was just an example of the setup of the query. If you look in your XML source for your report design and find the queryText property of the dataSet, you'll see what I'm talking about.
Idefix
Michael,
yes, I understood your post very well and of course I did not use that exact string ! ;-) I wrote my post to match with yours !
Of course I looked in my XML Source and found the queryText to replace.
I understand what you're talking about.
In my flat file (filename is "tempfile") there is only one column without header, something like this:
id1
id2
id3
In my XML Source I found the queryText:
select "COLUMN_1" from tempfile : {"COLUMN_1","COLUMN_1",STRING}
I set the beforeOpen method of this dataset to
this.query = "select 'COLUMN_1' from " + param["RP_TempFileName"] + " : {'COLUMN_1','COLUMN_1',STRING}"
With this I get the javascript error
If I write
this.query = "select 'COLUMN_1' from tempfile2 :{'COLUMN_1','COLUMN_1',STRING}"
with tempfile2 beeing another file with same structure in the same directory as tempfile, it will be ignored.
Whats my mistake ?
mwilliams
Idefix,
I figured you understood, but I wanted to make sure...
Let me see if I can get one set up and then I'll post it in here if I get it working.
Idefix
Michael,
that would be great !
Today I tried the same with BIRT 2.5 with same problems.
mwilliams
Idefix,
If you use:
qry = this.queryText;
this.queryText = qry.replace("File1.csv", "File2.csv");
It works fine. Not sure what the problem is with replacing the whole string, but I'll let you know if I figure it out.
mwilliams
Idefix,
It's a problem with the single quotes. In the XML Source, double quotes are used, so if you replace all the single quotes in what I told you earlier with " it will work.
mwilliams
Idefix,<br />
<br />
Virgil also made an example of how to do this for the devShare. He put the binding change in the dataSet editor under the property binding section. So, in the last 3 posts I've put in here, there are 3 similar, yet different, ways to do this.
<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/949-switch-text-datasource-at-runtime/#description'>Switch
Text DataSource at runtime - Designs & Code - BIRT Exchange</a>
shivkumar150
<p>Hi Williams,</p>
<p>Its too late, but still may help someone. So to pass the file as a parameter, I created a report parameter named "file" and in the beforeOpen method of dataset, wrote the following:</p>
<pre class="_prettyXprint">
this.queryText="select \"Employee Name\", \"Work\" from "+params["file.csv"].value+" :{\"KPEmployee\", \"Object\",STRING;\"Work Count\",\"Work\",INTEGER}";</pre>
<p>So in Williams solutions, it should be <strong>params["file"].value</strong> instead of <strong>param["file"]</strong>.</p>
<p>And you need to escape those double quotes (" ") with (\" \") in the Javascript.</p>