<?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: Convert bytes to kilobytes (tFileProperties) in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319288#M89552</link>
    <description>&lt;P&gt;Not a problem @Stéphane Barbezier​. Computers use base 2. This is because the smallest unit (bit) is capable of holding 2 states (0 or 1). There are 8 bits in a byte (00000000 = 0 and 11111111 = 255 ....so there are 256 possible numbers in a byte). There are 1024 bytes in a kilobyte.  However, some companies have made this simpler for people who use base 10 (most of us) and have converted that 1000. It is best to stick to 1024 in my opinion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The letter L after the hardcoded number tells the processor that the hardcoded number should be considered a long and not an int. That is all it is for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are you trying to round to? A whole number or a number of decimal places? &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of code to round to 2 decimal places can be seen below.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;B&gt;new&lt;/B&gt; java.text.DecimalFormat("0.00")).format(((double)input_row.size)/((double)1024L))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should work, but you'll need to test it to be sure.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2022 18:34:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-25T18:34:12Z</dc:date>
    <item>
      <title>Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319285#M89549</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I would like to make a calculation on the data I get with the component tFileProperties. This one gives me the size of the file in bytes as below :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxfU0AAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/131055iB5E4FBAB8B8020F1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxfU0AAJ.png" alt="0695b00000UxfU0AAJ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxfTRAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155716i620C078E90575659/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxfTRAAZ.png" alt="0695b00000UxfTRAAZ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I want to have it in kilobytes. To do this, I have to multiply the value by 0.001. But how to do the calculation?&lt;/P&gt;&lt;P&gt;The type of the column returned by the component (size) is Long&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxfUtAAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145971i5285AA9CE8123382/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxfUtAAJ.png" alt="0695b00000UxfUtAAJ.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxfVDAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157146iF02BF144628276CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxfVDAAZ.png" alt="0695b00000UxfVDAAZ.png" /&gt;&lt;/span&gt;I tried that, but it doesn't work&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxgdwAAB.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157290iEB56C523EC413079/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxgdwAAB.png" alt="0695b00000UxgdwAAB.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 22:37:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319285#M89549</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2024-11-15T22:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319286#M89550</link>
      <description>&lt;P&gt;There are 1024 bytes in a kilobyte, so you need to divide your value by 1024 to get the kilobyte value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Longs are whole numbers. They are essentially integers. Due to this, you need to cast them to doubles. To do this, do something like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;((&lt;B&gt;double&lt;/B&gt;)row5.size)/((&lt;B&gt;double&lt;/B&gt;)1024L)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will cast the size to a double and cast the 1024L (a hardcoded long....just as an example) to a double. The division of the double size and double 1024 will give you the answer you need.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 15:54:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319286#M89550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-25T15:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319287#M89551</link>
      <description>&lt;P&gt;Thank you very much for your clear answer @Richard Hall​&amp;nbsp;. For information, I found the formula for converting bytes to kilobytes here :&amp;nbsp;&lt;A href="https://www.dataunitconverter.com/byte-to-kilobyte" alt="https://www.dataunitconverter.com/byte-to-kilobyte" target="_blank"&gt;Convert Bytes to kB - Bytes to Kilobytes Calculator (dataunitconverter.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Yours is correct, I tested both and there is a small difference (62.3 dividing by 1024 and 63.8 multiplying by 0.001).&lt;/P&gt;&lt;P&gt;Here is my file:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000Uxi7TAAR.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/147798i31FFE1C7073DB44A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000Uxi7TAAR.png" alt="0695b00000Uxi7TAAR.png" /&gt;&lt;/span&gt;Is there a big importance to add L after 1024? what does it mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would now like to round this result, I tried the functions round() and Math.round(((double)input_row.size)/((double)1024L));&lt;/P&gt;&lt;P&gt;But without success&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 17:02:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319287#M89551</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-08-25T17:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319288#M89552</link>
      <description>&lt;P&gt;Not a problem @Stéphane Barbezier​. Computers use base 2. This is because the smallest unit (bit) is capable of holding 2 states (0 or 1). There are 8 bits in a byte (00000000 = 0 and 11111111 = 255 ....so there are 256 possible numbers in a byte). There are 1024 bytes in a kilobyte.  However, some companies have made this simpler for people who use base 10 (most of us) and have converted that 1000. It is best to stick to 1024 in my opinion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The letter L after the hardcoded number tells the processor that the hardcoded number should be considered a long and not an int. That is all it is for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are you trying to round to? A whole number or a number of decimal places? &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of code to round to 2 decimal places can be seen below.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;B&gt;new&lt;/B&gt; java.text.DecimalFormat("0.00")).format(((double)input_row.size)/((double)1024L))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should work, but you'll need to test it to be sure.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 18:34:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319288#M89552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-25T18:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319289#M89553</link>
      <description>&lt;P&gt;Thanks again @Richard Hall​&amp;nbsp; for the very interesting explanations!&lt;/P&gt;&lt;P&gt;I'm just trying to convert my decimal value obtained for kilobytes to integer without decimal.&lt;/P&gt;&lt;P&gt;With your code I get the following error :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxjOcAAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/158284i69FDE069AF7DFD31/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxjOcAAJ.png" alt="0695b00000UxjOcAAJ.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000UxjQHAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/144427iF823CF60D4BF4672/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000UxjQHAAZ.png" alt="0695b00000UxjQHAAZ.png" /&gt;&lt;/span&gt;Type mismatch : cannot convert from String to Double&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to obtain for example 62 instead of 62.3 or 64 instead of 63.8&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 19:13:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319289#M89553</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-08-25T19:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319290#M89554</link>
      <description>&lt;P&gt;@Richard Hall​&amp;nbsp; Searching in other forums, I made a solution that is close to what I want, here it is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Double.parseDouble(String.format("%.0f",((double)input_row.size)/((double)1024L)).replace(",", "."));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have 62.0 for example&lt;/P&gt;&lt;P&gt;if 5f then I would have 5 decimals after the 62.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I would like to get just 62. Any idea?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 19:54:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319290#M89554</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-08-25T19:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319291#M89555</link>
      <description>&lt;P&gt;Ah, sorry. I assumed that you wanted to display the figure. When you truncate or round a number like above, it formats it as a String. You can fix this by changing your column type (on the right) to String. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to round the number to a whole number (rounding up to the next whole number or down, depending on &amp;gt;=0.5 or &amp;lt;0.5) then Math.round is the method you need.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:03:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319291#M89555</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-25T20:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Convert bytes to kilobytes (tFileProperties)</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319292#M89556</link>
      <description>&lt;P&gt;Indeed, I was searching without knowing in which type I want my final result. Looking at the database column that should store my result, it is of type string with two decimals. Finally, the following code satisfies me perfectly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String.format("%.2f",((double)input_row.size)/((double)1024L))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's true that having the result in integer type would have interested me also for my personal practice, but I'll look for another time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help @Richard Hall​&amp;nbsp;!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:33:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Convert-bytes-to-kilobytes-tFileProperties/m-p/2319292#M89556</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-08-25T20:33:05Z</dc:date>
    </item>
  </channel>
</rss>

