Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Binary File as Input

Hi, from what I've read in other forum entries, it's not possible to use binary files as an input. I DO know the exact data structure and I have a little plain Java source snippet which is capable extracting the data from the binary file.

Is there any way I can use that little Java snippet as a generator for an input, just like the tFileInput..... components are?
In an ideal world, I would fill the output_row fields within each iteration of my Java loop, just like that:

output_row.field1 = field1;
output_row.field2 = field2;
...


Any advise would be appreciated.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I think I've got the solution.
[list=1]
  • tJava: create an ArrayList

  • tJava: loops over the binary file and put elements into the ArrayList

  • tJava: at the end of the loop, put the ArrayList into the global Map

  • Later:
    tJavaFlex / Start Code:
    java.util.Iterator<Tick> al = ((java.util.ArrayList<Tick>)globalMap.get("ticks")).iterator();

    while (al.hasNext()) {

    tJavaFlex / Main Code:

    Tick ti = al.next();
    row2.milliseconds = ti.getMilliseconds();
    row2.ask = ti.getAsk();
    row2.bid = ti.getBid();
    row2.askv = ti.getAskv();
    row2.bidv = ti.getBidv();


    tJavaFlex / End Code:

    }


    And that creates the flow. I think the memory usage peaks a little, but the files are not longer than 1-2MB, so that shouldn't be too much of an issue. Very cool, this brings me a huge leap forward. Thank you Talend!!

    View solution in original post

    1 Reply
    Anonymous
    Not applicable
    Author

    I think I've got the solution.
    [list=1]
  • tJava: create an ArrayList

  • tJava: loops over the binary file and put elements into the ArrayList

  • tJava: at the end of the loop, put the ArrayList into the global Map

  • Later:
    tJavaFlex / Start Code:
    java.util.Iterator<Tick> al = ((java.util.ArrayList<Tick>)globalMap.get("ticks")).iterator();

    while (al.hasNext()) {

    tJavaFlex / Main Code:

    Tick ti = al.next();
    row2.milliseconds = ti.getMilliseconds();
    row2.ask = ti.getAsk();
    row2.bid = ti.getBid();
    row2.askv = ti.getAskv();
    row2.bidv = ti.getBidv();


    tJavaFlex / End Code:

    }


    And that creates the flow. I think the memory usage peaks a little, but the files are not longer than 1-2MB, so that shouldn't be too much of an issue. Very cool, this brings me a huge leap forward. Thank you Talend!!