<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Parsing data from .txt file</title><link>https://community.appian.com/discussions/f/general/18267/parsing-data-from-txt-file</link><description>HI all, 
 
 I&amp;#39;m trying to parse data from a .txt file which contains data as mentioned below using readTextFromFile() function. 
 Text in file :&amp;quot; 1 abc def xyz 02/02/2020 aaa zzz&amp;quot; 
 ouput of readTextFromFile() function : &amp;quot;1 abc def xyz 02/02/2020 aaa</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71921?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 18:38:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e9412791-1c4a-4097-9da5-95ddc881c6d1</guid><dc:creator>GauravSingh</dc:creator><description>&lt;p&gt;Yes Mike Split worked for me.&lt;/p&gt;
&lt;p&gt;I have used below code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!fileData: readtextfromfile(&lt;br /&gt; txtFile:ri!file,&lt;br /&gt; preserveLineBreaks:true()&lt;br /&gt; ),&lt;br /&gt; local!dataArray: if(&lt;br /&gt; rule!APN_isEmpty(local!fileData),&lt;br /&gt; {},&lt;br /&gt; a!forEach(&lt;br /&gt; items: split(&lt;br /&gt; local!fileData, &lt;br /&gt; rule!APN_replaceNull(fn!char(9), &amp;quot;;&amp;quot;)&lt;br /&gt; ),&lt;br /&gt; expression: trim(fv!item)&lt;br /&gt; )&lt;br /&gt; ),&lt;br /&gt; local!dataArray&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71920?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 18:37:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4c7dba1c-ca1b-4010-a21d-2bb02c7448c1</guid><dc:creator>GauravSingh</dc:creator><description>&lt;p&gt;Yes Peter, split() function worked form me, it was just i have used fn!char(9) to replace the blank space.&lt;/p&gt;
&lt;p&gt;I have used below Code Snippet to get the resolution.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt; local!fileData: readtextfromfile(&lt;br /&gt; txtFile:ri!file,&lt;br /&gt; preserveLineBreaks:true()&lt;br /&gt; ),&lt;br /&gt; local!dataArray: if(&lt;br /&gt; rule!APN_isEmpty(local!fileData),&lt;br /&gt; {},&lt;br /&gt; a!forEach(&lt;br /&gt; items: split(&lt;br /&gt; local!fileData, &lt;br /&gt; rule!APN_replaceNull(fn!char(9), &amp;quot;;&amp;quot;)&lt;br /&gt; ),&lt;br /&gt; expression: trim(fv!item)&lt;br /&gt; )&lt;br /&gt; ),&lt;br /&gt; local!dataArray&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71902?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 13:51:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:abd33c95-9256-4516-b2e4-f9a7986d0f53</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Did the split() function work for your use case? I&amp;#39;m a bit unclear what the issue is now because that should generate an array with each of the items separated. If it doesn&amp;#39;t work with a space (&amp;quot; &amp;quot;), you might need to find whatever character is separating the items and use char(&amp;lt;your character number here&amp;gt;) as the separator in the split function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71900?ContentTypeID=1</link><pubDate>Wed, 05 Feb 2020 13:45:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d012f516-0b52-432a-9edc-5b002c6c9168</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I half suspect that the text file might be tab-separated (just based on how it looks when pasted here), and then the Appian expression output is just trimming those tabs down to single spaces.&amp;nbsp; Either way this should be easy to parse, but might require extra handling in the rule.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71886?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2020 21:42:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:55e49d43-b936-4640-9673-14409b8e934c</guid><dc:creator>GauravSingh</dc:creator><description>&lt;p&gt;I&amp;#39;m getting data from a third party application in a .txt file from where i have to read the data and prepare an excel template.&lt;/p&gt;
&lt;p&gt;once i am able to get the data in form of array then leaving&amp;nbsp;the data at index 1 and index 2 rest will be used form the cdt for the excel.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;i.e if input file has data as: &amp;quot;&lt;span&gt;1 abc def xyz 02/02/2020 aaa zzz&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;then generated excel will be something like below&lt;/span&gt;&lt;/p&gt;
&lt;table width="329"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="64"&gt;def&lt;/td&gt;
&lt;td width="64"&gt;xyz&lt;/td&gt;
&lt;td width="64"&gt;02-02-2020&lt;/td&gt;
&lt;td width="64"&gt;aaa&lt;/td&gt;
&lt;td width="64"&gt;&amp;nbsp;zzz&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And with this approach we have prepare the excel template from 3 input files&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parsing data from .txt file</title><link>https://community.appian.com/thread/71885?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2020 21:31:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:33ef6d17-ae2b-4823-8b43-1d8efc69eb99</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;#160;fn!split(&amp;quot;1 abc def xyz 02/02/2020 aaa zzz&amp;quot;, &amp;quot; &amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t find any documentation that supports the the behavior you describe as expected.&amp;nbsp; How did you arrive at that conclusion?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>