Contents of a csv file

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

Shoma_Costco

Posts: 17
Joined: Thu May 08, 2014 2:07 am

Post by Shoma_Costco » Thu Jun 05, 2014 7:46 pm
I need to get the contents of a csv file to be sent as one of the elements in a soap request to call a web service. When I use set variable to get contents (specifying file path), the data set in the variable is all junk values and not real data. Also my file is relatively large having customer related details. Could you please help with this requirement using Goanywhere.

Support_Jon

Support Specialist
Posts: 62
Joined: Thu Jul 19, 2012 9:15 am
Location: Ashland, NE

Post by Support_Jon » Thu Jun 12, 2014 8:00 am
Shoma,

You should be able to set your variable to the file needed and include that as the value of your XML element as in this example.
Code: Select all
<project name="CSV in XML" mainModule="Main" version="2.0">

	<module name="Main">

		<setVariable label="set variable to file contents" name="contents" inputFile="/linoma/goanywhere/userdata/documents/user/sample.csv" version="2.0" />


		<print label="print file contents to job log" version="1.0">
			<![CDATA[-- begin file contents --
${contents}
-- end file contents --]]>
		</print>


		<xmlWrite label="write XML" outputFile="/linoma/goanywhere/userdata/documents/user/output.xml" version="1.0">
			<header><?xml version="1.0" encoding="UTF-8" ?></header>
			<element name="file" value="${contents}" />
		</xmlWrite>

	</module>

</project>

If you have issues with the appearance of the file contents, please verify the encoding of your input csv file. You may need to specify that on the set variable task and may also need to adjust the header of your XML to specify proper encoding as well.
Code: Select all
<setVariable label="set variable to file contents" name="contents" inputFile="/linoma/goanywhere/userdata/documents/user/sample.csv" encoding="utf-8" version="2.0" />
I hope this helps you out.

Thanks - Jon
2 posts Page 1 of 1