Author Topic: Python help!  (Read 1227 times)

Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Python help!
« on: July 24, 2012, »
I've posted this question on some of the Python boards, however, since I'm new to the programming language I think what I'm conveying is getting lost in translation. 

Instead of trying to post everything that's been asked/answered, here is the hyperlink to my question:

You are not allowed to view links. Register or Login

Any thoughts/suggestions on how to solve this issue would be very helpful!

Steve
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login

Offline TexasStingray

  • Coop Manager
  • Sr. Member
  • *
  • Posts: 791
Re: Python help!
« Reply #1 on: July 24, 2012, »
What you really need to do is post what the data currently looks like and what you want it to look like once its been processed.
Scott Wanner
TX

Watch my videos
You are not allowed to view links. Register or Login

Offline kgustafson

  • Coop Manager
  • Sr. Member
  • *
  • Posts: 1120
    • Lost Weekend Productions
Re: Python help!
« Reply #2 on: July 25, 2012, »
Try this to set your CSV correctly (this simply reads your CSV file and writes it back out as is to filename):
Code: You are not allowed to view links. Register or Login
import csv

ifile  = open('test.csv', "rb")
reader = csv.reader(ifile)
ofile  = open(filename, "wb")
writer = csv.writer(ofile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)

for row in reader:
    writer.writerow(row)

ifile.close()
ofile.close()

With the limited info you have provided it looks like you have your columns and rows buggered (looking at the example you posted for [frames]

I think you want the output to look like this :  [(255, 0), (0,   171), (0,  205), (255, 0),...etc].  I think maybe the zip command is not doing what you think it should.  Try it without the zip command.  Outside of this, not sure without more information.

Kurt
------
Visit at: You are not allowed to view links. Register or Login

Offline kgustafson

  • Coop Manager
  • Sr. Member
  • *
  • Posts: 1120
    • Lost Weekend Productions
Re: Python help!
« Reply #3 on: July 25, 2012, »
Further look at this.  Remember the unzip command (zip(*zipholder)) is expecting to parse out to x number of variables where x is the width of your array.  For example, if you have the following in zipholder [(1,2,3,4),(4,5,6,7),(7,8,9,10)] and you ran zip(*zipholder), it would be looking to copy the three sub-arrays into four variables

Code: You are not allowed to view links. Register or Login
var1, var2, var3, var4 = zip(*zipholder)

This code would have var1 = [1,4,7], var2 = [2,5,8], var3 = [3,6,9], and var4 = [4,7,10]

Not sure if this helps any.  But this is where I would look in your code for why the columns and rows are transposed.

Kurt

------
Visit at: You are not allowed to view links. Register or Login

Offline mms

  • Sr. Member
  • ****
  • Posts: 421
  • 80124
    • Like us on Facebook for special content and year-round updates.
Re: Python help!
« Reply #4 on: July 25, 2012, »
I think I have it figured out.  Thanks as always for the help!
Like us on Facebook for special content and year-round updates: You are not allowed to view links. Register or Login

Voice-over Inquiries:  You are not allowed to view links. Register or Login

Offline kgustafson

  • Coop Manager
  • Sr. Member
  • *
  • Posts: 1120
    • Lost Weekend Productions
Re: Python help!
« Reply #5 on: July 26, 2012, »
Glad you got it working.
------
Visit at: You are not allowed to view links. Register or Login