-2
Hello! My question is the following: I wrote a program that, with the information I enter, it will collect a number of links (that number varies) and will store them in a csv. Then he will open each of these links and collect some data, saving them in another csv. The problem is in this second part...
When we use something like " csvFile = open('.csv file', 'wt+') ", it will create a file called File.csv. The point is that my program will do this several times in a row, and if I keep the name the way it is it will not create an Archive(1). csv (as windows usually do with files of the same name), it will overwrite one file on top of the other. If the amount of times my program runs was predefined, I could write Think as many times as needed, the problem is that it is not, it can run it 10 times, or 1000, etc...
How can I make my program to create a csv with the collected data, and in the following link it creates a different csv, without replacing the previous file? Type 1.csv File, 2.csv File, 3.csv File, etc. This is possible?
Thanks in advance.
Jordan, can you make the question a little clearer? What have you tried to do? What exactly is your question? I ask why the
open()
opens a file for read/write, if you want to open another file just run anotheropen()
and write to another file.– fernandosavio
Well, when we use something like " csvFile = open('.csv file', 'wt+') ", it will create a file called File.csv. The point is that my program will do this several times in a row, and if I keep the name the way it is it will not create an Archive(1). csv (as windows usually do with files of the same name), it will overwrite one file on top of the other. If the amount of times my program runs was predefined, I could write Think as many times as needed, the problem is that it is not, it can run it 10 times, or 1000, etc...
– Jordan Garcia
Jordan, the most effective way is for you to edit the question with these clarifications. This way it is easier to understand your question, your question goes back to the top of the most recent questions and votes to close your question temporarily can be canceled.
– fernandosavio
Thanks for the tip, I updated there.
– Jordan Garcia
Names should be dynamic. You can use the date and time in the file name, you can have another file that saves the last created file name, you can also read the files in the folder to find out which is the last one... there are several approaches. You just need to decide which one helps you the most. .
– fernandosavio
I don’t think I’ve been exactly clear yet. Suppose the program runs 5 times. It will not generate 5 csv files with the same name, but only 1, with the data collected from the last run.
– Jordan Garcia
The structure would then be, a main file with the links and a file for each link you have in that main file?
– fernandosavio
Fernando, that’s right!
– Jordan Garcia