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

  • SEARCH
  • Home
  • 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 6841409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:57:46+00:00 2026-05-26T23:57:46+00:00

I am trying to use the API in cutplace to build a custom check

  • 0

I am trying to use the API in cutplace to build a custom check
http://cutplace.sourceforge.net/api.html#writing-checks

Using the included demo data and code I have tried to follow the manual, at least until it ends abruptly.

useCutplace.py:

# Validate a test CSV file.
import os.path
from cutplace import interface
from cutplace import checks
from cutplace import ranges

class FullNameLengthIsInRangeCheck(checks.AbstractCheck):
    """Check that total length of customer name is within the specified range."""
    def __init__(self, description, rule, availableFieldNames, location=None):
        super(FullNameLengthIsInRangeCheck, self).__init__(description, rule, availableFieldNames, location)
        self._fullNameRange = ranges.Range(rule)
        self.reset()
def checkRow(self, rowMap, location):
    fullName = rowMap["last_name"] + ", " + rowMap["first_name"]
    fullNameLength = len(fullName)
    try:
        self._fullNameRange.validate("full name", fullNameLength)
    except ranges.RangeValueError, error:
        raise CheckError("full name length is %d but must be in range %s: %r" \
                % (fullNameLength, self._fullNameRange, fullName))

icdPath = os.path.join("icd_customers_field_names_only.csv")
dataPath = os.path.join("customers.csv")
icd = interface.InterfaceControlDocument()
icd.read(icdPath)
for row in interface.validatedRows(icd, dataPath):
    print row

The interface control document with custom check:

,Interface: customers,
,,
,Data format,
D,Format,CSV
D,Header,1
,,
,Fields,
,Name,
F,branch_id,
F,customer_id,
F,first_name,
F,surname,
F,gender,
F,date_of_birth,

C,"full name must have at most 100 characters",FullNameLengthIsInRange,:100

customers.csv

Branch id,Customer id,First name,Surname,Gender,Date of birth
38000,16,Daisy,Mason,female,27.02.1946
38000,42,Wendy,Davis,female,30.12.1971
38000,57,Keith,Parker,male,02.06.1984
38000,76,Kenneth,Tucker,male,15.11.1908
38053,11,Carlos,Barrett,male,09.02.1929
38053,20,Terrance,Hart,male,11.03.1961
38053,34,Lori,Dunn,female,26.09.1996
38053,73,Mary,Sutton,female,09.12.1982
38053,83,Lorraine,Castro,female,15.08.1978
38111,16,Esther,Newman,female,23.03.1932
38111,79,Tyler,Rose,male,17.12.1920
38111,127,Andrew,Dixon,male,02.10.1913

The error

>python useCutplace.py 
Traceback (most recent call last):
  File "useCutplace.py", line 29, in <module>
    icd.read(icdPath)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cutplace-0.6.7-py2.6.egg/cutplace/interface.py", line 406, in read
    self._processRow(icdRowToProcess)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cutplace-0.6.7-py2.6.egg/cutplace/interface.py", line 363, in _processRow
    self.addCheck(icdRowToProcess[1:])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cutplace-0.6.7-py2.6.egg/cutplace/interface.py", line 339, in addCheck
    checkClass = self._createCheckClass(checkType)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cutplace-0.6.7-py2.6.egg/cutplace/interface.py", line 171, in _createCheckClass
    return self._createClass("checks", checkType, "Check", "check")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cutplace-0.6.7-py2.6.egg/cutplace/interface.py", line 162, in _createClass
    raise fields.FieldSyntaxError("cannot find %s: %s" % (typeName, str(type)), self._location)
cutplace.fields.FieldSyntaxError: icd_customers_field_names_only.csv (R16C1): cannot find check: FullNameLengthIsInRange
  • 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-05-26T23:57:47+00:00Added an answer on May 26, 2026 at 11:57 pm

    OK the trick is to:
    Put the class inside a separate module, which here I call mychecks.py

    from cutplace import checks
    from cutplace import ranges
    
    class FullNameLengthIsInRangeCheck(checks.AbstractCheck):
        """Check that total length of customer name is within the specified range."""
        def __init__(self, description, rule, availableFieldNames, location=None):
            super(FullNameLengthIsInRangeCheck, self).__init__(description, rule, availableFieldNames, location)
            self._fullNameRange = ranges.Range(rule)
            self.reset()
    def checkRow(self, rowMap, location):
        fullName = rowMap["surname"] + ", " + rowMap["first_name"]
        fullNameLength = len(fullName)
        try:
            self._fullNameRange.validate("full name", fullNameLength)
        except ranges.RangeValueError, error:
            raise checks.CheckError("full name length is %d but must be in range %s: %r" \
                    % (fullNameLength, self._fullNameRange, fullName))
    

    Explicitly name that module in the icd:

    ,Interface: customers,
    ,,
    ,Data format,
    D,Format,CSV
    D,Header,1
    ,,
    ,Fields,
    ,Name,
    F,branch_id,
    F,customer_id,
    F,first_name,
    F,surname,
    F,gender,
    F,date_of_birth,
    
    C,"full name must have at most 100 characters",mychecks.FullNameLengthIsInRange,:10
    

    The module must be in the PYTHONPATH or in the immediate directory. It does not appear that you can create a package containing the module that cutplace can see.

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

Sidebar

Related Questions

I've trying to use the API for CapsuleCRM... http://capsulecrm.com/help/page/api_gettingstarted I've been reading some articles
I trying to use twitter API to send direct messages using C# but Twitter
I'm trying to use windows' API IsTextUnicode to check if a character input is
I'm trying to use the Stream.BeginWrite Async I/O API in .NET for a high-throughput
I am trying to use Dozer Java API to map two java classes using
I'm trying to use the .net API library to get a single image by
I'm trying to use google analytics API to retrieve some data to build a
I am trying to use native windows API with Qt using mingw toolset. There
I'm trying to use an API under Delphi. Here's the API documentation: OKERR ENTRY
I'm trying to use the sharepoint API to deploy some solutions and the global

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.