<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Accessing abc.csv AS/400 files</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/as400-45/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-45/</link>
	<description></description>
	<lastBuildDate>Wed, 19 Jun 2013 13:10:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/as400-45/#comment-90529</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 06 Apr 2011 20:45:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-90529</guid>
		<description><![CDATA[There are two general ways to use the .CVS data. You can convert (copy) it into a database format and access the resulting data in the database file. Or you can use the &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Funix2.htm&quot;&gt;open(), read() and close() Unix APIs&lt;/a&gt; to read lines directly from the .CVS file into RPG or other HLL program. At V5R4 and later, it&#039;s fairly easy even in ILE CL.

To convert to a database format, create a physical file with fields that match the columns in the .CVS file. Generally, you only need to match data types. That is, if you have a column in the .CVS that holds a FirstName of a person, you don&#039;t need to count how many characters are in the column -- just create a character field in your file that is big enough to hold any first name. You can use DDS to create a PF or SQL to CREATE TABLE. Once you have a file that can receive the values, use the CPYFRMIMPF command to run the conversion.

Alternatively, you can create a PF with a single large character field, big enough to hold the longest line in the .CVS file. Use CPYFRMSTMF to copy the lines into the flat PF and then read the lines in RPG record by record. You still need to write instructions to parse through those lines to break out each data value, so the CPYFRMIMPF method can be easier unless non-standard formatting is used.

If you need to go with the Unix APIs, you should consider coding in C. There are alternative &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=/rtref/sc41560702.htm&quot;&gt;C library functions&lt;/a&gt; -- fopen(), fgets() and fclose() -- that make a lot of logic easier. It&#039;s possible to kind of use those in other ILE languages, but you need to decipher the macros to track down what &lt;i&gt;really&lt;/i&gt; gets called by those library functions and what their parms are, and then call those actual APIs in your RPG (or CL or whatever).

Tom]]></description>
		<content:encoded><![CDATA[<p>There are two general ways to use the .CVS data. You can convert (copy) it into a database format and access the resulting data in the database file. Or you can use the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Funix2.htm">open(), read() and close() Unix APIs</a> to read lines directly from the .CVS file into RPG or other HLL program. At V5R4 and later, it&#8217;s fairly easy even in ILE CL.</p>
<p>To convert to a database format, create a physical file with fields that match the columns in the .CVS file. Generally, you only need to match data types. That is, if you have a column in the .CVS that holds a FirstName of a person, you don&#8217;t need to count how many characters are in the column &#8212; just create a character field in your file that is big enough to hold any first name. You can use DDS to create a PF or SQL to CREATE TABLE. Once you have a file that can receive the values, use the CPYFRMIMPF command to run the conversion.</p>
<p>Alternatively, you can create a PF with a single large character field, big enough to hold the longest line in the .CVS file. Use CPYFRMSTMF to copy the lines into the flat PF and then read the lines in RPG record by record. You still need to write instructions to parse through those lines to break out each data value, so the CPYFRMIMPF method can be easier unless non-standard formatting is used.</p>
<p>If you need to go with the Unix APIs, you should consider coding in C. There are alternative <a href="http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=/rtref/sc41560702.htm">C library functions</a> &#8212; fopen(), fgets() and fclose() &#8212; that make a lot of logic easier. It&#8217;s possible to kind of use those in other ILE languages, but you need to decipher the macros to track down what <i>really</i> gets called by those library functions and what their parms are, and then call those actual APIs in your RPG (or CL or whatever).</p>
<p>Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.031 seconds using memcached
Object Caching 267/273 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-06-19 13:40:11 -->