× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Fri, Aug 16, 2013 at 1:42 AM, Luis Rodriguez <luisro58@xxxxxxxxx> wrote:
I had never thought of using SQL in order to read a stream file until I saw
your posts. I have to admit that the idea looks very interesting and hope
to get a little free time in order to check it out.

Birgitta's article (which I've only briefly skimmed) seems
well-written and informative, as I think most of us have come to
expect from her. However, it's not something you can check out if you
only have "a little free time" as it's quite long and detailed. Which
is also to be expected, given the nature of the tools being used.

If you really only have a *little* free time, I seriously recommend
looking at Python instead. iSeriesPython is free, easily installable,
doesn't require any interaction with PASE (at least as far as you are
concerned), and crucially: handles both IFS stream and QSYS.LIB files
effortlessly. The latter can be manipulated via SQL or native RLA.

And for the specific task of parsing CSVs, it has the added cherry on
top of including a CSV library so you don't have to roll your own.
Don't forget that you have to beware of delimiter characters embedded
in the literal data (which is kind of how this thread started), and if
the CSV comes from Excel (or programs that use Excel's conventions),
you have to be careful about handling quotes as well as field
delimiters. Python's CSV module takes care of all of that for you.

If all your fields happen to be text, I can give you iSeriesPython
code to copy CSV to PF right here, in 7 lines:

import csv
pf = File400('OUTPUTPF', 'a')
with open('input.csv', 'r') as f:
for row in csv.reader(f):
for i in range(pf.fieldCount()):
pf.set(i, row[i])
pf.write()

That's it! It's not hard to extend that to check the PF field types
and coerce the CSV values accordingly.

John

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.