On Fri, May 3, 2013 at 4:16 PM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:
Reading Excel may be easier in python... but once you have the data and
need to put it into your databases, I suspect that part will be easier
in RPG.

For most cases, I doubt it. iSeriesPython is quite adept with QSYS
files, accessed either via record-level access (a la classic RPG) or
SQL.

If you have an Excel file named MyFile.xls and you already have a
physical file named MYFILE with the proper fields to receive it, you
could do something like

import xlrd

f = File400('MYFILE', 'a', lib='*LIBL')
wb = xlrd.open_workbook('MyFile.xls')
ws = wb.sheet_by_index(0) # get the first (and probably only) sheet
for r in range(ws.nrows):
values = ws.row_values(r)
for c, value in enumerate(values):
f[c] = value
f.write()
f.close()

That is it. You are done. You have copied all of MyFile.xls into MYFILE.

John

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2026 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.