<?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 loading different field names for different file names in loop in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/loading-different-field-names-for-different-file-names-in-loop/m-p/1025466#M643644</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to start off by wishing you all a happy new year!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My first question of 2016 is about looping using if conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have multiple csv files from which I would like to load different field names, depending on which csv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written a loop that can load all fields from all csv files by simply using making a table that includes all filenames in the folder and the header sizes per csv file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for i= 0 to noofrows('Mwoah')-1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET myfilename = peek('SourceFile',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET headersize = peek('Headersize',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load *&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NEXT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I would like to amend this script so that if the filename contains a certain text string, it should load specific fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use an if...then clausule for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking about using this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for i= 0 to noofrows('table1')-1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET myfilename = peek('SourceFile',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET headersize = peek('Headersize',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF substringcount($(myfilename),'TRD_ETD_VAL')&amp;gt;0 then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;nieuwetabel:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load filename() as Filename,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Party 1 Transaction ID] as [Transaction ID],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Message Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Transaction Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Action,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Prefix (Pos)],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Value (Pos)] as UTI&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;elseif substringcount($(myfilename),'TRD_ETD_TX')&amp;gt;0 then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load filename() as Filename,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Party 1 Transaction ID] as [Transaction ID],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Message Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Transaction Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Action],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Prefix (TX)] as [UTI Prefix],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Value (TX)] as UTI&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;endif;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NEXT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I load this script I get the error message that the line &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;elseif substringcount($(myfilename),'TRD_ETD_TX')&amp;gt;0 then &lt;/STRONG&gt;is false. What do I need to do to get this script working? Note that the loop should check whether the filename contains a certain string, and if it does it should load the appropriate file names, if it does not contain the string it should proceed to test whether the filename contains another text string and if it does it should load appropriate file names, if it does not, it should proceed to the next condition and so on, and so forth. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jan 2016 11:26:58 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-01-05T11:26:58Z</dc:date>
    <item>
      <title>loading different field names for different file names in loop</title>
      <link>https://community.qlik.com/t5/QlikView/loading-different-field-names-for-different-file-names-in-loop/m-p/1025466#M643644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to start off by wishing you all a happy new year!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My first question of 2016 is about looping using if conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have multiple csv files from which I would like to load different field names, depending on which csv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written a loop that can load all fields from all csv files by simply using making a table that includes all filenames in the folder and the header sizes per csv file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for i= 0 to noofrows('Mwoah')-1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET myfilename = peek('SourceFile',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET headersize = peek('Headersize',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load *&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NEXT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I would like to amend this script so that if the filename contains a certain text string, it should load specific fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use an if...then clausule for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking about using this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for i= 0 to noofrows('table1')-1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET myfilename = peek('SourceFile',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LET headersize = peek('Headersize',$(i),'table1');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF substringcount($(myfilename),'TRD_ETD_VAL')&amp;gt;0 then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;nieuwetabel:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load filename() as Filename,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Party 1 Transaction ID] as [Transaction ID],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Message Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Transaction Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Action,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Prefix (Pos)],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Value (Pos)] as UTI&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;elseif substringcount($(myfilename),'TRD_ETD_TX')&amp;gt;0 then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load filename() as Filename,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Party 1 Transaction ID] as [Transaction ID],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Message Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Transaction Type],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[Action],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Prefix (TX)] as [UTI Prefix],&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[UTI Value (TX)] as UTI&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [$(myfilename)]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is $(headersize) lines);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;endif;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NEXT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I load this script I get the error message that the line &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;elseif substringcount($(myfilename),'TRD_ETD_TX')&amp;gt;0 then &lt;/STRONG&gt;is false. What do I need to do to get this script working? Note that the loop should check whether the filename contains a certain string, and if it does it should load the appropriate file names, if it does not contain the string it should proceed to test whether the filename contains another text string and if it does it should load appropriate file names, if it does not, it should proceed to the next condition and so on, and so forth. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2016 11:26:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loading-different-field-names-for-different-file-names-in-loop/m-p/1025466#M643644</guid>
      <dc:creator />
      <dc:date>2016-01-05T11:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: loading different field names for different file names in loop</title>
      <link>https://community.qlik.com/t5/QlikView/loading-different-field-names-for-different-file-names-in-loop/m-p/1025467#M643645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe using single quotes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;elseif substringcount(&lt;STRONG style=": ; color: #ff0000; font-size: 14pt;"&gt;'&lt;/STRONG&gt;$(myfilename)&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style=": ; color: #ff0000; font-size: 14pt;"&gt;'&lt;/STRONG&gt;&lt;/EM&gt;,'TRD_ETD_TX')&amp;gt;0 then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;hope this helps&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;regards&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Marco&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:47:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loading-different-field-names-for-different-file-names-in-loop/m-p/1025467#M643645</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2016-01-05T22:47:25Z</dc:date>
    </item>
  </channel>
</rss>

