Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:37:25+00:00 2026-06-01T23:37:25+00:00

This is the first time I’ve used ReportLab, I have tried to edit an

  • 0

This is the first time I’ve used ReportLab, I have tried to edit an existing script that does exactly what I want to do, but I get the following error, when I try and run the script.

Script –

import os, arcgisscripting, datetime, getpass, string

from reportlab.lib.pagesizes import A4
from reportlab.platypus import *
from reportlab.lib import colors
from reportlab.lib.styles import ParagraphStyle

myWorkspace = r"W:\City.gdb"
myReportFolder = r"W:\Reports"
myLogosFolder = r"W:\Logos"
OpenPDF = "true"

gp = arcgisscripting.create(9.3)


#setup geoprocessor
gp.workspace = myWorkspace
gp.toolbox = "analysis"
gp.OverwriteOutput = 1
mySelectedGroupsFC = myWorkspace + os.sep + "SelectedGroups"
myNewBusinessFC = myWorkspace + os.sep + "New_Businesses"
myBufferFC = myWorkspace + os.sep + "Buffer"
myReportTable = myWorkspace + os.sep + "FINAL_TABLE"

#obtain Selected groups
mySelGroupsCursor = gp.searchcursor(mySelectedGroupsFC)
mySelectedGroups = mySelGroupsCursor.next()

#obtain New Business groups
myNewBusinessCursor = gp.searchcursor(myNewBusinessFC)
myNewBusiness = myNewBusinessCursor.next()

#obtain Buffer
myBufferCursor = gp.searchcursor(myBufferFC)
myBuffer = myBufferCursor.next()

#setup PDF doc
Author = getpass.getuser() #gets OS user name
pdf_file_name = myNewBusiness.POSTCODE
pdf_file = myReportFolder + os.sep + pdf_file_name + ".pdf"

doc = SimpleDocTemplate(pdf_file, pagesize=A4)

#array of report elements
parts = []

#
#HEADER
#
parstyle = ParagraphStyle(name='Title', fontName='Helvetica', fontSize=12, alignment=1, spaceAfter=20)
p = Paragraph('<b><u>Report</u></b>', parstyle)
parts.append(p)

p = Paragraph('The following community groups are located within <b><u>' + myBuffer.Buffer + 'metres  of -  <b><u>' + myNewBusiness.Postcode + '<\b><\u>.',parstyle)
parts.append(p)

#
#TABLE
#

while myBuffer:
    parstyle = ParagraphStyle(name='Title', fontName='Helvetica', fontSize=11, alignment=0, spaceAfter=15, spaceBefore =15)
    p = Paragraph('<b><u>Community groups within ' + myBuffer.Buffer + ' metres of ' + myNewBusiness.Postcode  + '</u><\b>', parstyle)
    parts.append(p)

    data = []
    parstyle = ParagraphStyle(name='Title', fontName='Helvetica', fontSize=11, alignment=0)    

    while mySelectedGroups:
        selectedGroups_desc = 'Community ID:'+ '<i>' + mySelectedGroups.Community_ID + '<\i>' + 'Organisation Name :' + mySelectedGroups.Organisation_Name  
        p = Paragraph(selectedGroups_desc, parstyle)
        mySelectedGroups = mySelGroupsCursor.next()


    #build and format table
    t=Table(data, colWidths=(100,100))
    t.setStyle(TableStyle([
        ('ALIGN',(0,0),(-1,-1),'CENTER'),
        ('VALIGN',(0,0),(-1,-1),'TOP'),
        ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
        ('BOX', (0,0), (-1,-1), 0.25, colors.black),
        ('TOPPADDING', (0,0), (-1,-1), 10),
        ]))
    parts.append(t)

myBuffer = myBufferCursor.next()

#Footnote
parstyle = ParagraphStyle(name='Title', fontName='Helvetica', fontSize=11, alignment=0, spaceAfter=15, spaceBefore=15)
p = Paragraph('''Should you have any further questions **''', parstyle)
parts.append(p)


#Build document
doc.build(parts)

del mySelGroupsCursor, myNewBusinessCursor, myBufferCursor

#Open document
if OpenPDF == "true":
    os.startfile(pdf_file)

The error that I get is:

Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
    exec codeObject in __main__.__dict__
  File "H:\Report_v2.py", line 100, in <module>
    t=Table(data, colWidths=(100,100))
  File "C:\Python25\Lib\site-packages\reportlab\platypus\tables.py", line 236, in __init__
    raise ValueError("%s must have at least a row and column" % self.identity())
ValueError: <Table@0x010F4710 0 rows x unknown cols>... must have at least a row and column

Any ideas what I need to do as I am struggling a bit.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:37:27+00:00Added an answer on June 1, 2026 at 11:37 pm

    From the error and the code, the problem appears to be that data is an empty array []. ReportLab seems to choke on this, so you just need to actually supply some data to the table t and it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time posting here, I have a question which I have
This is the first time ever I'm using AJAX, and I want to do
I have two update panels at my ajax page. This is first time I'm
So here I have this first time app I'm working on. When I run
I have tableview that scroll vertically. My question is when first this view is
This is first time that I work with json. I am trying to return
I am new to databases, in fact this is first time. I want to
this is first time i'm develope paypal form , i have problem with shipping
This is my first time on StackOverflow though I read Coding Horror quite often.
This is the first time I'm creating an open-source project, and I've decided (based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.