how to access abc.csv files in as400.i have a abc.csv file,in this file have contain some data but i want to access into my physical file,with out using 3rd party tool.pls give advice
Software/Hardware used:
software
ASKED:
April 6, 2011 4:49 PM
UPDATED:
April 6, 2011 8:45 PM
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 open(), read() and close() Unix APIs to read lines directly from the .CVS file into RPG or other HLL program. At V5R4 and later, it’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’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 C library functions — fopen(), fgets() and fclose() — that make a lot of logic easier. It’s possible to kind of use those in other ILE languages, but you need to decipher the macros to track down what really 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