Reading a CSV file for comparing data
Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
2 posts
Page 1 of 1
Hi all, I have a project that involves reading a CSV file and comparing a column from the file to a data variable.
I am retrieving the name of the day of the week (Mon, Thu, etc) using the set variable function into variable TodayIs. I have a CSV file that has 7 rows corresponding to the days of the week. To mix things up a little, Sat is day 1, Sun is day 2, up through Fri is day 7.
I read the csv file and create a rowset named ReturnDay.
Then I want a for-each-loop to read the rowset and compare the first column to the TodayIs variable and return the second column if equal. the error I get says they are different types of variables.
how do I define these to be both character variables? My xml is below.
Kevin
I am retrieving the name of the day of the week (Mon, Thu, etc) using the set variable function into variable TodayIs. I have a CSV file that has 7 rows corresponding to the days of the week. To mix things up a little, Sat is day 1, Sun is day 2, up through Fri is day 7.
I read the csv file and create a rowset named ReturnDay.
Then I want a for-each-loop to read the rowset and compare the first column to the TodayIs variable and return the second column if equal. the error I get says they are different types of variables.
how do I define these to be both character variables? My xml is below.
Code: Select all
TIA, <project name="Get Promotions files" mainModule="Main" version="2.0" logLevel="debug">
<description>retrieve promotion files from crm7promo</description>
<import file="D:\GoAnywhere\userdata\projects\VARIABLES\VAR_Common_AS400.xml" />
<variable name="TodayIs" value="xxx" description="3 letter Name of Day" />
<variable name="daynum" value="6" description="Day of week number Saturday = 1, Sunday = 2, Friday = 7 " />
<module name="Main" logLevel="debug">
<!--comment-->
<createWorkspace label="Create Workspace" version="1.0" />
<callModule label="Call Module" module="VarAS400" version="1.0" />
<setVariable name="TodayIs" value="${CurrentDate('E')}" version="2.0" />
<readCSV inputFile="D:\GoAnywhere\userdata\Aptos\Daynumber.csv" outputRowSetVariable="ReturnDay" version="1.0">
<data trim="both">
<column index="1" name="dayname" size="3" type="VARCHAR" trim="right" />
<column index="2" name="daynumber" size="1" type="INTEGER" />
</data>
</readCSV>
<forEachLoop itemsVariable="${ReturnDay}" currentItemVariable="row">
<print version="1.0" disabled="false">
<![CDATA[Return Day = ${ReturnDay}
row = ${row}]]>
</print>
<if label="compare day name" condition="${dayname eq TodayIs}" disabled="true">
<setVariable label="set day number" name="daynumb" value="${daynumber}" version="2.0" />
</if>
<exitLoop condition="${5 eq 1}" />
</forEachLoop>
<deleteWorkspace label="Delete Workspace" version="1.0" disabled="true" />
</module>
</project>
Kevin
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
Kevin,
Try putting a "String()" around each variable .. so, you end up comparing apples to apples.
${ string( dayname ) eq string( TodayIs ) }
Try putting a "String()" around each variable .. so, you end up comparing apples to apples.
${ string( dayname ) eq string( TodayIs ) }
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts
Page 1 of 1