Sep-06-2017, 11:31 PM
I'm having issues with my code where I'm getting 'str' object is not callable error, but I'm not assigning anything to str, and the rest of the variable assignments look right. Likewise, parentheses are properly placed, so far as I can tell. Strings also seemly properly enclosed with single or double quotes (see code below).
#!/usr/local/bin/python3.4 import re, sys, time, logging, os, platform, pprint, configparser def ParseSpreadsheet(cfg): ranges_per_field = cfg["data"]["cell_ranges"].split('\n') flds = () for range in ranges_per_field: (cols, start_row, end_row) = range.split() #print("Cols is " + str(cols) + ", start row is " + str(start_row) +", end row is " + str(end_row)) col_list = cols.split(',') for row in list(range(int(start_row), int(end_row))): print(str(row)) cfg = configparser.ConfigParser() cfg.read('test.cfg') ParseSpreadsheet(cfg)This is the configuration file it reads:
$ cat test.cfg [input] infile = Broadcast Server Naming Convention.xlsx #infile = your_file.xlsx [data] tab_name = Field Data # Format is: # start column for field end column for field end row for field # For example, B D 380 means data starts in column B, ends in D, and starts row 4, ends at row 380 fld_lengths = 3,3,3,4,2,5,0 # Domain name has no limit cell_ranges = B,C,D 4 380 F,G,H 4 380 J,K,L 4 200 N,O,P 4 200 R,S,T 4 4 V,W,X 4 50 Y,Z,AA 4 50And I get this when I run it:
$ ./test.py Traceback (most recent call last): File "./test.py", line 21, in <module> ParseSpreadsheet(cfg) File "./test.py", line 15, in ParseSpreadsheet for row in list(range(int(start_row), int(end_row))): TypeError: 'str' object is not callableAny thoughts on why I'm getting this?