444,002 Members | 1,050 Online
Need help? Post your question and get tips & solutions from a community of 444,002 IT Pros & Developers. It's quick & easy.

# How to loop to make many .csv files?

 P: 27 Hey guy! I have a couple questions, which I don't think are too advanced. I created an algorithm called "Best" for simplicity I will not include the mathematical details of it. I ask the user to input 6 values: Stock, min,win,Stop,GO, and end. Looking at the last 5 inputs, they are all integer inputs eg: 1,2,3. This code will take my algorithm and spit out a csv file called "boom.csv" with two columns of numbers based on the input values. My questions are as follow: -Can a loop be made so i input 3 integers for each user input, then spit out one .csv file for each combination of user input values? I know I would need to some how create a way to name the .csv files for each combination of user inputs, but how would I do that? Also how would I make a loop that can look at each combination of the user input values? So with 3 integers per 5 input values, that should be 3^5 outputs. Thank you for any help! Ron Parker Expand|Select|Wrap|Line Numbers #!/usr/bin/python import  numpy import csv       def Best(seq):     ALGORITHM   Stock=raw_input('Stock Symbol: ' )   min=raw_input('Start time (min away from open) : ' ) win=raw_input('Window (min): ' ) Stop=raw_input('SL: ' ) Go=raw_input('PL: ' ) end=raw_input('End time (min away from open) : ' )     Entry=[ Best(something1[ i:i+120]) for i in range(0, len(something1), 120)] Entry2=[float(item[0]) for item in Entry] Entry3=[float(item[1]) for item in Entry]       myFile= open( "Boom.csv", "wb" ) wtr= csv.writer( myFile ) for Start, Exit, in zip(Entry2,Entry3):     aRow=Start     bRow=Exit     cRow=[aRow,bRow]     wtr.writerow(cRow)   myFile.close()   Jan 11 '11 #1