<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Binary File as Input in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369691#M132815</link>
    <description>Hi 
&lt;BR /&gt;Welcome to Talend Community! 
&lt;BR /&gt;I'm afraid there isn't any component to extract fields from binary file directly now. 
&lt;BR /&gt;For your request, the resolution may be a little complex. 
&lt;BR /&gt;First step, create routines and hard code in it. 
&lt;BR /&gt;The Java code below is just an example. 
&lt;BR /&gt;Maybe you have to change some logic. 
&lt;BR /&gt; 
&lt;PRE&gt;1010111 1101000 1100001 1110100 100000 1100001 &lt;BR /&gt;100000 1101110 1101001 1100011 1100101 100000 1100100 &lt;BR /&gt;1100001 1111001 100001&lt;BR /&gt;//TESTED BINARY DATA&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;public static String toStr(String binStr){&lt;BR /&gt;        String[] tempStr = StrToStrArray(binStr);&lt;BR /&gt;        char[] tempChar = new char;&lt;BR /&gt;        for(int i = 0; i &amp;lt; tempStr.length; i++){&lt;BR /&gt;            tempChar&lt;I&gt; = toChar(tempStr&lt;I&gt;);&lt;BR /&gt;        }&lt;BR /&gt;        return String.valueOf(tempChar);&lt;BR /&gt;    }&lt;BR /&gt;    private static String[] StrToStrArray(String str){&lt;BR /&gt;        return str.split(" ");&lt;BR /&gt;    }&lt;BR /&gt;    private static char toChar(String binStr){&lt;BR /&gt;        int[] temp = binStrToIntArray(binStr);&lt;BR /&gt;        int sum = 0;&lt;BR /&gt;       &lt;BR /&gt;        for(int i = 0; i &amp;lt; temp.length; i++){&lt;BR /&gt;            sum += temp &amp;lt;&amp;lt; i;&lt;BR /&gt;        }&lt;BR /&gt;   &lt;BR /&gt;        return (char)sum;&lt;BR /&gt;       &lt;BR /&gt;    }&lt;BR /&gt;    private static int[] binStrToIntArray(String binStr){&lt;BR /&gt;        &lt;BR /&gt;        char[] temp = binStr.toCharArray();&lt;BR /&gt;        int[] result = new int;&lt;BR /&gt;   &lt;BR /&gt;        for(int i = 0; i &amp;lt; temp.length; i++){&lt;BR /&gt;            result&lt;I&gt; = temp&lt;I&gt; - 48;&lt;BR /&gt;        }&lt;BR /&gt;        return result;&lt;BR /&gt;       &lt;BR /&gt;    }&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; 
&lt;BR /&gt;Then create a job as the following images. 
&lt;BR /&gt;If you want to extract fileds, you have to use tExtractRegexFields. 
&lt;BR /&gt;Regards, 
&lt;BR /&gt;Pedro</description>
    <pubDate>Fri, 13 Jan 2012 06:05:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-01-13T06:05:11Z</dc:date>
    <item>
      <title>Binary File as Input</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369690#M132814</link>
      <description>I am a newbie to TOS and Java, but am learning quickly. I have been trying to figure out how to use a binary file as an input and then parse out the different fields in the file. I have found a couple posts about binary files, but none of them answered my question. I don't see any file input components that would work for a binary file. I looked at the tFileInputFullRow, but there isn't a distinguishable row delimiter, so that was out. I was given a Java program that parses the file, but not sure how to incorporate that into an input. Is there a way that I could modify this program to use it is an input source that pulls in the binary file or do I need to convert the file outside of Talend into a "temporary" file and then pull that file in using Talend? Any thoughts would be greatly appreciated. Thank you.</description>
      <pubDate>Sat, 16 Nov 2024 12:27:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369690#M132814</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T12:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Binary File as Input</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369691#M132815</link>
      <description>Hi 
&lt;BR /&gt;Welcome to Talend Community! 
&lt;BR /&gt;I'm afraid there isn't any component to extract fields from binary file directly now. 
&lt;BR /&gt;For your request, the resolution may be a little complex. 
&lt;BR /&gt;First step, create routines and hard code in it. 
&lt;BR /&gt;The Java code below is just an example. 
&lt;BR /&gt;Maybe you have to change some logic. 
&lt;BR /&gt; 
&lt;PRE&gt;1010111 1101000 1100001 1110100 100000 1100001 &lt;BR /&gt;100000 1101110 1101001 1100011 1100101 100000 1100100 &lt;BR /&gt;1100001 1111001 100001&lt;BR /&gt;//TESTED BINARY DATA&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;public static String toStr(String binStr){&lt;BR /&gt;        String[] tempStr = StrToStrArray(binStr);&lt;BR /&gt;        char[] tempChar = new char;&lt;BR /&gt;        for(int i = 0; i &amp;lt; tempStr.length; i++){&lt;BR /&gt;            tempChar&lt;I&gt; = toChar(tempStr&lt;I&gt;);&lt;BR /&gt;        }&lt;BR /&gt;        return String.valueOf(tempChar);&lt;BR /&gt;    }&lt;BR /&gt;    private static String[] StrToStrArray(String str){&lt;BR /&gt;        return str.split(" ");&lt;BR /&gt;    }&lt;BR /&gt;    private static char toChar(String binStr){&lt;BR /&gt;        int[] temp = binStrToIntArray(binStr);&lt;BR /&gt;        int sum = 0;&lt;BR /&gt;       &lt;BR /&gt;        for(int i = 0; i &amp;lt; temp.length; i++){&lt;BR /&gt;            sum += temp &amp;lt;&amp;lt; i;&lt;BR /&gt;        }&lt;BR /&gt;   &lt;BR /&gt;        return (char)sum;&lt;BR /&gt;       &lt;BR /&gt;    }&lt;BR /&gt;    private static int[] binStrToIntArray(String binStr){&lt;BR /&gt;        &lt;BR /&gt;        char[] temp = binStr.toCharArray();&lt;BR /&gt;        int[] result = new int;&lt;BR /&gt;   &lt;BR /&gt;        for(int i = 0; i &amp;lt; temp.length; i++){&lt;BR /&gt;            result&lt;I&gt; = temp&lt;I&gt; - 48;&lt;BR /&gt;        }&lt;BR /&gt;        return result;&lt;BR /&gt;       &lt;BR /&gt;    }&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; 
&lt;BR /&gt;Then create a job as the following images. 
&lt;BR /&gt;If you want to extract fileds, you have to use tExtractRegexFields. 
&lt;BR /&gt;Regards, 
&lt;BR /&gt;Pedro</description>
      <pubDate>Fri, 13 Jan 2012 06:05:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369691#M132815</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-01-13T06:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Binary File as Input</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369692#M132816</link>
      <description>Thank you so much Pedro!  I'll give this a try and let you know if I have any questions.</description>
      <pubDate>Fri, 13 Jan 2012 12:12:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369692#M132816</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-01-13T12:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Binary File as Input</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369693#M132817</link>
      <description>I've been working on this and am having a little bit of trouble. My file is a little bit different. It seems to be encrypted to an extent, so the Java code reads each individual byte in the file and converts it. The program I currently have uses the FileInputStream to load the file and then converts that to a DataInputStream. Unfortunately, there isn't a line break that is visible in the file until the byte is read and converted. I haven't been able to figure out how to convert the program to a routine though mainly because I don't know what type of input to use so I can call the routine in tMap. Here's a snippet of the code: 
&lt;BR /&gt; 
&lt;PRE&gt;public class Test_ {&lt;BR /&gt;	public static void main (String[] args) {&lt;BR /&gt;		File file = null;&lt;BR /&gt;		int    i = 0;&lt;BR /&gt;		int    i_data = 0;&lt;BR /&gt;		byte   b_data = 0;&lt;BR /&gt;		try {&lt;BR /&gt;			FileInputStream file_input = new FileInputStream (file);&lt;BR /&gt;			DataInputStream data_in    = new DataInputStream (file_input);&lt;BR /&gt;			PrintStream out = new PrintStream(args);&lt;BR /&gt;			try {&lt;BR /&gt;				while(true)&lt;BR /&gt;				{&lt;BR /&gt;					i_data = data_in.readInt ();&lt;BR /&gt;					i_data = swapInt(i_data);&lt;BR /&gt;					out.printf("%d;",i_data);&lt;BR /&gt;					i_data = data_in.readInt ();&lt;BR /&gt;					i_data = swapInt(i_data);&lt;BR /&gt;					out.printf("%04d;",i_data);&lt;BR /&gt;					i_data = data_in.readInt ();&lt;BR /&gt;					i_data = swapInt(i_data);&lt;BR /&gt;					out.printf("%04d;",i_data);&lt;BR /&gt;					b_data = data_in.readByte ();&lt;BR /&gt;					out.printf("%d;",b_data &amp;amp; 128);&lt;BR /&gt;					out.printf("%c",data_in.readByte());&lt;BR /&gt;					for (i=0;i&amp;lt;8;i++)&lt;BR /&gt;					{&lt;BR /&gt;						out.printf("%c",data_in.readByte());&lt;BR /&gt;					}&lt;BR /&gt;					out.printf("%c;",data_in.readByte());&lt;BR /&gt;					out.printf("%c%n",data_in.readByte());&lt;BR /&gt;					out.printf("",data_in.readByte());&lt;BR /&gt;				} // While&lt;BR /&gt;			}&lt;BR /&gt;			catch (EOFException eof) {&lt;BR /&gt;			}&lt;BR /&gt;			data_in.close ();&lt;BR /&gt;			out.close ();&lt;BR /&gt;		} catch  (IOException e) {&lt;BR /&gt;		}&lt;BR /&gt;	} &lt;BR /&gt;}&lt;/PRE&gt; 
&lt;BR /&gt;I did create a a couple of jobs that convert the original file to a text file and then load the text file into the database, but I assume this is slower than it would be if I could do it in one step using a routine and tMap. 
&lt;BR /&gt;I apologize if this is straightforward. I appreciate any assistance.</description>
      <pubDate>Tue, 17 Jan 2012 14:24:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369693#M132817</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-01-17T14:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Binary File as Input</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369694#M132818</link>
      <description>I just wanted to give another update on this. I did some additional work and was able to make a little more progress. First of all, I changed my original process that was working to use a routine instead of a program called from a tSystem component, so it is all within TOS. I also was able to work with another routine that does something similar and able to call it within tMap. I also figured out that I could potentially use a tFileInputPositional with the specified length of the file. Unfortunately, the first 8 bytes are a header record and I'm not sure how to ignore that when the other rows are 500 bytes. I also tried to use a tFileInputFullRow and put the entire file into a single row. Not sure what the maximum length allowed is, but if I were able to do that, I can use the routine to parse the file. I'm not sure how to split the results into different rows since it would all be in the same field. I am starting to think that the only solution is to parse the file into a text file and then load that file into the database. I am open to any suggestions. Thank you.</description>
      <pubDate>Wed, 18 Jan 2012 02:38:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Binary-File-as-Input/m-p/2369694#M132818</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-01-18T02:38:20Z</dc:date>
    </item>
  </channel>
</rss>

