[Tutor] error message
Steven Buck
buckstec at gmail.com
Wed Jul 8 22:35:34 CEST 2009
As Bob prescribed, I added (and made sure to indent):
print self._header['byteorder'], fmt, byt
The fourth printed line appears to be the same:
Out[4]: {0: 22, 1: 51, 2: 42}
This is consistent with what I observe as the first three age observations
in the Stata data editor.
I include the rest of the error message I received (& could capture) below.
Any more thoughts?
Thanks
Steve
< b ▬
< b §
< b ☺
< b ☺
< b ☺
< b ☻
< b ☺
< f PCF
< b ♣
< f ∞Qê@
< b ☺
< f `A
< b ☺
< b ♣
< f
< f
< b
< b
< b ♣
< h ╥
< f ßC
< b e
< b ♣
< b
< b
< b
< b ☺
< b ♥
< b ♥
< b ☺
< h ñ
< h
< f 5î─D
< b ☺
< b
< b
< b
< b
< b
< b ☺
< b ☺
< h Σ☺
< b ☺
< b ☺
< f ÉB
< f ÜÖôB
< f ÜÖêB
< f âB
< f ═╠ƒB
< f ÜÖàB
< f ÜÖúB
< f ffzB
< f ═╠ùB
< f fféB
< f ffrB
< f 33æB
< f ∞Q8?
< f ü↓ⁿ@
< f «1¿╛
< f b♥2A
< f ¥o at A
< f ♠·OA
< f ╟▌QA
< f Ç?
< h ⌠←
< b
< h ║
< h <☻
< f áîF
< f
< h (♣
< f èE
< h
< h ╝
< h
< f α½F
< f
< f α½F
< f ╥E
< f hαF
< f }E
< b "
< b ☺
< b ☻
< b 3
< b 1
< b ☺
< b ☻
< b ☺
< b ☺
< b ☺
< f α½F
< b e
< f Å┬1A
< b
< f ,B
< b ♣
< b ♣
< f
< f
< b
< b ☺
< b ♣
< h
< f
< b e
< b ☺
< b ☺
< b
< b
< b ☻
< b ☺
< b ☺
< b ☻
< h ç
< h
< f 8↑sE
< b
< b ☺
< b
< b
< b ☺
< b
< b
< b
< h )
< b ☺
< b
< f ÉB
< f ÜÖôB
< f ÜÖêB
< f âB
< f ═╠ƒB
< f ÜÖàB
< f ÜÖúB
< f ffzB
< f ═╠ùB
< f fféB
< f ffrB
< f 33æB
< f ∞Q8?
< f ≥Ä♂A
< f «1¿╛
< f ░₧CA
< f _iXA
< f ↑├`A
< f ♫»iA
< f Ç@
< h àD
< b ☺
< h ║
< h Ñ♥
< f
< f Ç╨D
< h
< f ☻E
< h
< h ╚♠
< h
< f @£E
< f
< f @£E
< f
< f @£E
< f
< b
< b ☻
< b ☻
< b *
< b )
< b ☺
< b
< b ☺
< b ☺
< b ☺
< f @£E
< b ☺
< f ∞Q8@
< b
< f Ç?
< b ☺
< b ♣
< f
< f
< b
< b
< b ♣
< h
< f
< b e
< b ♣
< b
< b
< b
< b ☻
< b ☻
< b ☻
< b ♥
< h É
< h
< f ^ë↑D
< b
< b
< b ☺
< b
< b
< b ☺
< b
< b
< h Σ♠
< b ☺
< b
< f ÉB
< f ÜÖôB
< f ÜÖêB
< f âB
< f ═╠ƒB
< f ÜÖàB
< f ÜÖúB
< f ffzB
< f ═╠ùB
< f fféB
< f ffrB
< f 33æB
< f ∞Q8?
< f ■■■@
< f «1¿╛
< f ä▐3A
< f :─CA
< f ¡♫RA
< f bVUA
< f @@
< h ▐►
< b
< h ║
< h ►►
< f
< f aD
< h X☻
< f Ç"E
< h
< h ÷
< h ≡
< f ╝TF
< f HD
< f αvF
< f
< f αvF
< f »D
< b ↑
< b ♣
< b ♣
< b
---------------------------------------------------------------------------
error Traceback (most recent call last)
C:\Documents and Settings\Steve\<ipython console> in <module>()
C:\Python26\lib\site-packages\StataTools.py in __getitem__(self, k)
85 if self._file.tell() != loc:
86 self._file.seek(loc)
---> 87 return self._next()
88
89 ### PyDTA private methods
C:\Python26\lib\site-packages\StataTools.py in _next(self)
168 else:
169 data[i] = self._unpack(typlist[i],
self._file.read(s
elf._col_size(i)))
170 return data
171 else:
--> 172 return map(lambda i: self._unpack(typlist[i],
self._file.rea
d(self._col_size(i))), range(self._header['nvar']))
C:\Python26\lib\site-packages\StataTools.py in <lambda>(i)
168 else:
169 data[i] = self._unpack(typlist[i],
self._file.read(s
elf._col_size(i)))
170 return data
171 else:
--> 172 return map(lambda i: self._unpack(typlist[i],
self._file.rea
d(self._col_size(i))), range(self._header['nvar']))
C:\Python26\lib\site-packages\StataTools.py in _unpack(self, fmt, byt)
149 def _unpack(self, fmt, byt):
150 print self._header['byteorder'], fmt, byt
--> 151 d = unpack(self._header['byteorder']+fmt, byt)[0]
152 if fmt[-1] in self.MISSING_VALUES:
153 nmin, nmax = self.MISSING_VALUES[fmt[-1]]
error: unpack requires a string argument of length 1
In [4]: age
Out[4]: {0: 22, 1: 51, 2: 42}
In [5]:
On Wed, Jul 8, 2009 at 1:12 PM, bob gailer <bgailer at gmail.com> wrote:
> Steven Buck wrote:
>
> I'm running a for loop which returns an error message after the third
> iteration (see out[4] at the bottom as evidence). I don't understand the
> error message. Although I'll continue to do my own digging to debug, I
> thought I'd give you all a shot. Thanks, -steve
>
> Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
> (Intel)]
> Type "copyright", "credits" or "license" for more information.
> IPython 0.9.1 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help -> Python's own help system.
> object? -> Details about 'object'. ?object also works, ?? prints more.
> In [1]: import psid
> In [2]: age = {}
> In [3]: for i in range(len(psid.psid)):
> ...: age[(i)] = psid.psid[i][20]
> ...:
> ...:
> ---------------------------------------------------------------------------
> error Traceback (most recent call last)
> C:\Documents and Settings\Steve\<ipython console> in <module>()
> C:\Python26\lib\site-packages\StataTools.pyc in __getitem__(self, k)
> 85 if self._file.tell() != loc:
> 86 self._file.seek(loc)
> ---> 87 return self._next()
> 88
> 89 ### PyDTA private methods
>
> C:\Python26\lib\site-packages\StataTools.pyc in _next(self)
> 167 else:
> 168 data[i] = self._unpack(typlist[i],
> self._file.read(s
> elf._col_size(i)))
> 169 return data
> 170 else:
> --> 171 return map(lambda i: self._unpack(typlist[i],
> self._file.rea
> d(self._col_size(i))), range(self._header['nvar']))
> C:\Python26\lib\site-packages\StataTools.pyc in <lambda>(i)
> 167 else:
> 168 data[i] = self._unpack(typlist[i],
> self._file.read(s
> elf._col_size(i)))
> 169 return data
> 170 else:
> --> 171 return map(lambda i: self._unpack(typlist[i],
> self._file.rea
> d(self._col_size(i))), range(self._header['nvar']))
> C:\Python26\lib\site-packages\StataTools.pyc in _unpack(self, fmt, byt)
> 148
> 149 def _unpack(self, fmt, byt):
>
>
> Add here (temporarily) print self._header['byteorder'], fmt, byt
> make sure it is indented the same as 150.
> Let's examine the 4th printed line.
>
> --> 150 d = unpack(self._header['byteorder']+fmt, byt)[0]
> 151 if fmt[-1] in self.MISSING_VALUES:
> 152 nmin, nmax = self.MISSING_VALUES[fmt[-1]]
> error: unpack requires a string argument of length 1
> In [4]: age
> Out[4]: {0: 22, 1: 51, 2: 42}
> In [5]:
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.orghttp://mail.python.org/mailman/listinfo/tutor
>
>
>
> --
> Bob Gailer
> Chapel Hill NC
> 919-636-4239
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090708/cbd863fd/attachment-0001.htm>
More information about the Tutor
mailing list