473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to loop to make many .csv files?

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
  1. #!/usr/bin/python
  2. import  numpy
  3. import csv
  4.  
  5.  
  6.  
  7. def Best(seq):
  8.     ALGORITHM
  9.  
  10. Stock=raw_input('Stock Symbol: ' )
  11.  
  12. min=raw_input('Start time (min away from open) : ' )
  13. win=raw_input('Window (min): ' )
  14. Stop=raw_input('SL: ' )
  15. Go=raw_input('PL: ' )
  16. end=raw_input('End time (min away from open) : ' )
  17.  
  18.  
  19. Entry=[ Best(something1[ i:i+120]) for i in range(0, len(something1), 120)]
  20. Entry2=[float(item[0]) for item in Entry]
  21. Entry3=[float(item[1]) for item in Entry]
  22.  
  23.  
  24.  
  25. myFile= open( "Boom.csv", "wb" )
  26. wtr= csv.writer( myFile )
  27. for Start, Exit, in zip(Entry2,Entry3):
  28.     aRow=Start
  29.     bRow=Exit
  30.     cRow=[aRow,bRow]
  31.     wtr.writerow(cRow)
  32.  
  33. myFile.close()
  34.  
Jan 11 '11 #1
1 1949
bvdet
2,851 Expert Mod 2GB
I think you need a way to calculate all the possible permutations. A function that returns the permutations can be found here.

If you have a list of letters, a file name can be constructed thus:
Expand|Select|Wrap|Line Numbers
  1. >>> ext = "csv"
  2. >>> seq = ['a','b','c','d','e']
  3. >>> '.'.join(["".join(seq), ext])
  4. 'abcde.csv'
  5. >>> 
OR
Expand|Select|Wrap|Line Numbers
  1. >>> "%s.%s" % ("".join(seq), ext)
  2. 'abcde.csv'
  3. >>> 
Jan 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Efrat Regev | last post by:
Hello, I would like to recurse through a directory and make files (which match a specific criteria) read only. From searching the Internet, I found...
0
by: Frederic | last post by:
Hi, all, I am modifying a big program written by somebody else. When I modified some ".h" files, say a.h, then I run "make all", but I found out make didn't recompile those files which included...
2
by: sudheervemana | last post by:
Dear all, In my main directory there are some source files and i have another directory which includes several folders,each contains the make files.Now i want to debug my source code in either...
2
by: KevinGPO | last post by:
Just wondering if anyone knows if there are converters to convert from: MS Visual C++ 6.0 or MS Visual Studio 2003 project files into UNIX autogen/configure/make files?
2
by: gmamla | last post by:
I am trying to learn C++ using "Thinking in C++" from Bruce Eckel. I have installed cygwin and GNU make on my windows XP. The samples are working fine. I am trying to understand the makefile,...
6
by: Justin Fancy | last post by:
Hi Everyone, I'm lookin for a very confusing loop (to me), to compare two files. Here it is. I have two arrays with paths stored in both. example: /en/aviation/you.htm. I need to search array...
2
by: newbai | last post by:
I have a query.Hope someone can help me in this!!! A c++ code consists of include statements,main(),function defination ..now I want to make separte files.I mean the first file will be of only...
3
by: richie9648 | last post by:
Hi All I have created a macro which turns reports done by users into a format that is needed by me. The good this is that all the reports are in the same format. However my question is around...
2
by: Sin Jeong-hun | last post by:
Since Windows 2000, all user setting files should be stored separately in the user's application settings directory. But some users still want all the files to be created in the application folder,...
9
by: bowlderyu | last post by:
Hello, all. I meet a question about compiling files. Eg., I have three files named myfile.h, myfile.c and the main.c file, and there is a function, ex, void myfun(...). If I put myfun(...) in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.