<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Problem with AWK converter script]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/940/" />
	<updated>2009-06-22T18:22:35Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/940/problem-with-awk-converter-script/</id>
		<entry>
			<title type="html"><![CDATA[Problem with AWK converter script]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/2677/#p2677" />
			<content type="html"><![CDATA[<p>Hello, <br />I have some problem with data conversion, my data are received in the template like below (input.csv):<br /><em>(ticker,periodicity,date,hour,popen,phigh,plow,pclose,volume)<br />FW20U09_I,1,20090619,083300,1928.00,1928.00,1927.00,1927.00,44<br />FW20U09_I,1,20090619,083400,1927.00,1929.00,1926.00,1928.00,48<br />FW20U09_I,1,20090619,083600,1926.00,1928.00,1926.00,1928.00,43<br />FW20U09_I,1,20090619,083900,1929.00,1930.00,1929.00,1930.00,76<br />FW20U09_I,1,20090619,084000,1929.00,1930.00,1929.00,1929.00,198</em></p><p>To convert this data I prepared file script.txt:</p><p><em># AWK script<br />{<br />&nbsp; &nbsp; # Check the number of the columns<br />&nbsp; &nbsp; # We need of 9 columns<br />&nbsp; &nbsp; if(NF == 9)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; # Input file<br />&nbsp; &nbsp; &nbsp; &nbsp; # -----------------<br />&nbsp; &nbsp; &nbsp; &nbsp; ticker&nbsp; = $1;<br />&nbsp; &nbsp; &nbsp; &nbsp; period&nbsp; = $2;<br />&nbsp; &nbsp; &nbsp; &nbsp; date&nbsp; &nbsp; = $3;<br />&nbsp; &nbsp; &nbsp; &nbsp; time&nbsp; &nbsp; = $4;<br />&nbsp; &nbsp; &nbsp; &nbsp; popen&nbsp; &nbsp;= $5;<br />&nbsp; &nbsp; &nbsp; &nbsp; phigh&nbsp; &nbsp;= $6;<br />&nbsp; &nbsp; &nbsp; &nbsp; plow&nbsp; &nbsp; = $7;<br />&nbsp; &nbsp; &nbsp; &nbsp; pclose&nbsp; = $8;<br />&nbsp; &nbsp; &nbsp; &nbsp; volume&nbsp; = $9;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; # Convert the Date format from YYYYMMDD to YYYY-MM-DD<br />&nbsp; &nbsp; &nbsp; &nbsp; year&nbsp; = substr(date,1,4);<br />&nbsp; &nbsp; &nbsp; &nbsp; month = substr(date,5,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; day&nbsp; &nbsp;= substr(date,7,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; date = year &quot;-&quot; month &quot;-&quot; day;</em></p><p><em>&nbsp; &nbsp; &nbsp; &nbsp; # Converts the Time from HHMMSS to HH:MM<br />&nbsp; &nbsp; &nbsp; &nbsp; if(length(time) = 6)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hour = substr(time,1,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; min = substr(3,2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time = hour &quot;:&quot; min;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; # Output file<br />&nbsp; &nbsp; &nbsp; &nbsp; # ------------------<br />&nbsp; &nbsp; &nbsp; &nbsp; print date &quot;;&quot; time &quot;;&quot; popen &quot;;&quot; phigh &quot;;&quot; plow &quot;;&quot; pclose &quot;;&quot; volume;<br />&nbsp; &nbsp; }<br />}</em></p><p>But I received empty output.csv file(0 bytes), where could be a problem?<br />Regards,</p>]]></content>
			<author>
				<name><![CDATA[artuab]]></name>
				<uri>https://forexsb.com/forum/user/1136/</uri>
			</author>
			<updated>2009-06-22T18:22:35Z</updated>
			<id>https://forexsb.com/forum/post/2677/#p2677</id>
		</entry>
</feed>
