Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98894

Python: Why the file is beeing saved to wrong folder?

$
0
0

I dont get why this code is saving the csv file on the folder 'chats', and not the 'chatroom' folder.

The name of the csv must be the chatroom + in + timestr .csv

    #Make Selenium check the chatroom name
    chatroom = driver.find_element_by_class_name('_19vo_').text

    #Create a variable of a folder path with chatroom name
    chat_path = 'D:\Drive\Outros\Python\data_save\chats\ ' + chatroom

    #Verify if folder already exists, if not, create it
    Path(chat_path).mkdir(parents=True, exist_ok=True)

    #Save a df.csv to the chatroom folder
    df.to_csv(chat_path +chatroom+' in'+ timestr +' .csv', index=None, header=True, encoding='utf-8-sig')

The result of this, is a folder with the chatroom name, and a csv file named 'chatroomchatroom in...'


Viewing all articles
Browse latest Browse all 98894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>