I do this all the time in DB2 SQL but I'm creating CSV's.

I use List_Agg() to get all the data from syscolumns in one CSV row. Our DB is standardized around the TEXT() info not COLHDG() but the concept would be similar.

You'll probably want to be sure to "order by ordinal_position" to get them in the right sequence.

I'll be interested in seeing the Python solution with COLHDG() and formatting them as multi-line headers in Excel.


Roger Harman

COMMON Certified Application Developer - ILE RPG on IBM i on Power






________________________________
From: OpenSource <opensource-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Michael Fulmer <mfulmer@xxxxxxx>
Sent: Friday, December 3, 2021 1:12 PM
To: opensource@xxxxxxxxxxxxxxxxxx <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] Beginner Python Question about Db2 to Excel

Thanks so much, I'll give it a try.


Sent: Friday, December 03, 2021 at 4:06 PM
From: "John Yeung" <gallium.arsenide@xxxxxxxxx>
To: "IBMi Open Source Roundtable" <opensource@xxxxxxxxxxxxxxxxxx>
Subject: Re: [IBMiOSS] Beginner Python Question about Db2 to Excel
On Fri, Dec 3, 2021 at 3:37 PM Michael Fulmer <mfulmer@xxxxxxx> wrote:
>
> Does anyone know if it's possible to retrieve the Column Headings from
an
> IBM i DB2 DDS File and use them as Column Headings when creating an
Excel
> Spreadsheet using a Python Script with XLSXWRITER and Pandas?

Yes. Use the QSYS2.SYSCOLUMNS2 view. The column heading (as a 60-char
string, 20 chars for each "line" of COLHDG) is available as
COLUMN_HEADING. In case you are interested in the text, get it from
COLUMN_TEXT. Use TABLE_NAME and TABLE_SCHEMA to specify the file and
library, respectively. Be sure to use all caps for the file and
library.

Official documentation is here:

[1]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ibm.com%2Fdocs%2Fen%2Fi%2F7.3%3Ftopic%3Dviews-syscolumns2&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=syezrs7xSLJ1RT1biuKpWC1K3lR7oc1vYYHWN1DTFdI%3D&amp;reserved=0

John Y.
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: [2]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=3sCkx5cF%2FAnDtzMdJeGtwOYogM5zcpqvVZqkypls8Ic%3D&amp;reserved=0
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at [3]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=HfGfqZB2Oup28WQeRutu30armGH7zXj6GcDMtfZFFeI%3D&amp;reserved=0.

Help support midrange.com by shopping at amazon.com with our affiliate
link: [4]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com%2F&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=tld3GV%2BaWlFrEGqh39uudZR8Shi3yPJcrlcsZw79aeg%3D&amp;reserved=0

References

Visible links
1. https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ibm.com%2Fdocs%2Fen%2Fi%2F7.3%3Ftopic%3Dviews-syscolumns2&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=syezrs7xSLJ1RT1biuKpWC1K3lR7oc1vYYHWN1DTFdI%3D&amp;reserved=0
2. https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=3sCkx5cF%2FAnDtzMdJeGtwOYogM5zcpqvVZqkypls8Ic%3D&amp;reserved=0
3. https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833071112%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=HfGfqZB2Oup28WQeRutu30armGH7zXj6GcDMtfZFFeI%3D&amp;reserved=0
4. https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com%2F&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833081065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=J2ZSoACHjjFMT5pc%2BD8yZRnLY%2FASXgRUJOyQpnWsYOw%3D&amp;reserved=0
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833081065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=7HTVE8NUcUmM3VjJTRVsj8NCUg%2BgY97WPe%2Fdl3VZ6Rg%3D&amp;reserved=0
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fopensource&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833081065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=LAvRO2ikeHLXQ7snkwCMS6kKiZeK9MTzQuJrLnQAX48%3D&amp;reserved=0.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com%2F&amp;data=04%7C01%7C%7Ce5d75b58b63b45e6cc6808d9b6a1b04a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637741627833081065%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=J2ZSoACHjjFMT5pc%2BD8yZRnLY%2FASXgRUJOyQpnWsYOw%3D&amp;reserved=0

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-2022 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.