Jump to content
UBot Underground

How to load data from a .csv file and then save new data to a specific cell in that same .csv file?


Recommended Posts

I'm having some problems with saving new data to a pre-existing .csv file without overwriting data that's already in the file. I'm creating a bot that can sign up and submit to various web 2.0 sites. If I want to let ubot sign up to onsugar and weebly and the next day to blogspot I want ubot to save all the usernames and passwords to the same. csv file. The userdata.csv file will have details like the email address and the login details for each web 2.0 site as follows:

 

botbot@gmail.com,emailpass,adress,city,postalcode

onsugar,username,pass

weebly,username,pass

blogspot,username,pass

 

When my bot signs up to a web 2.0 site it needs to be able to retrieve the email address by loading a table cell from userdata.csv at row #0 and column #0.

 

Then the bot will pick a random username and password to fill in the fields during sign up. Since I want to save the username and password to the userdata.csv file, I've tried using 'set table cell' to add the username and password to a new table. Then I tried to save the data of the new table to userdata.csv. But that makes ubot overwrite the userdata.csv with only the new username and password.

 

Then I tried to let ubot load the data in userdata.csv file and save the new table in userdata.csv, but that just overwrites userdata.csv not saving anything at all, leaving me with an empty csv. file... I created a small script to demonstrate what I'm trying to do.

 

To sum it all up, during a sign up I want to be able load data from a specific.csv file (like an email address) and then save a new piece of data (like a username) to a specific cell in that same .csv file.

 

I wish ubot had the option to 'save to file' in a way that does not overwrite the old file but instead overwrites the cells specified. I hope someone can help me do this even without such an option.

 

Thanks in advance

fail2.ubot

Link to post
Share on other sites

What is the purpose of the file you are loading into your Table?

 

The reason I ask is that you are over-writing that data in the Table almost as soon as you load the Table. SO that is why it appears to be changing data when you save it.

Link to post
Share on other sites

Hi Patrick. One way you can accomplish this is to load the csv file into a table and create a sub that loops through the columns and places the contents into a list (or lists if you have more than one column/row). That way as you add to the list it does not overwrite the existing content. When you are done with the lists, you can then add them to a table as a column (or row) and save the table as a new csv file.

 

John

Link to post
Share on other sites

Hi JohnB. I'm still pretty new to UBot so I'm having a hard time figuring out how to do what you're suggesting. Any chance you could perhaps edit the .ubot file I added so I can see what you mean? Also I'm planning to have 50+ rows in the .csv file.

 

Thanks

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...