Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Wrapping statements in Python in SPSS

Reply
Thread Tools

Wrapping statements in Python in SPSS

 
 
Mitya Sirenef
Guest
Posts: n/a
 
      12-28-2012
On 12/28/2012 01:05 PM, Mitya Sirenef wrote:
> On 12/28/2012 12:55 PM, Mitya Sirenef wrote:
>> On 12/28/2012 12:33 PM, wrote:
>>> I think 396 just comes from the end of the Python loop, without

indicating which line in the loop is
>> at issue.
>> >
>> > Here is the full code from this section of the loop:
>> >
>> >
>> > for (
>> > msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6,

dspd7, dspd8, dspd9, dspd10, dspd11, dspd12,
>> > period1, period2, period3, period4, period5, period6, period7,

period8, period9, period10, period11, period12
>> > ) in zip(
>> > Measure, BreakVariable, Dimension, Sources,

DimensionSourceTimeFrame1, DimensionSourceTimeFrame2,
DimensionSourceTimeFrame3, DimensionSourceTimeFrame4,
>> > DimensionSourceTimeFrame5, DimensionSourceTimeFrame6,

DimensionSourceTimeFrame7, DimensionSourceTimeFrame8,
DimensionSourceTimeFrame9,
>> > DimensionSourceTimeFrame10, DimensionSourceTimeFrame11,

DimensionSourceTimeFrame12,
>> > TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5,

TimeFrame6, TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10,
TimeFrame11, TimeFrame12
>> > ):
>> >
>> >
>> > spss.Submit(r"""
>> >
>> >
>> > Alan
>> >
>> >

>>
>> By the way, when lines run so long they can get hard to manage, edit,
>> understand, et cetera. You should consider setting things up cleanly
>> before doing the loop and using a list of names for columns like so:
>>
>>
>> def main():
>> l1, l2 = [1,2], [3,4]
>> zipped = zip(l1, l2)
>> colnames = "first second".split()
>>
>> for columns in zipped:
>> coldict = dict(zip(colnames, columns))
>> print("coldict", coldict)
>>

>
>
> Should really be 'for column in zipped:' !
>
> -m
>


Doh - the code is good, but I got a little confused with variable names.
This should be more like it:

def main():
c1, c2 = [1,2], [3,4]
zipped = zip(c1, c2)
colnames = "first second".split()

for values in zipped:
valdict = dict(zip(colnames, values))
print("valdict", valdict)

main()


-m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Training and Projects on Bioinformatics, SAS, SPSS, ComputationalBiology and Clinical Research @ SANCTUARY BIO-LABS, Hyderabad SANCTUARY BIO-LABS C++ 0 07-25-2009 10:17 AM
SPSS Silvio Bierman Java 0 02-14-2008 11:22 PM
how to put data from a sql server table into spss format? Mark ASP .Net 0 12-26-2007 05:20 PM
component statements within architecture statements Neil Zanella VHDL 8 10-20-2006 09:05 AM
SPSS Mike Schwab Ruby 2 12-03-2005 12:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57