Whenever I execute the script, it keeps publishing only the first row from the CSV file repeatedly

I need assistance with a script I have created to upload images to a website from a CSV file. However, each time I run the script, it only uploads the first row of data. Here is an excerpt from the script where I attempt to publish all images, descriptions, tags, titles, and colors from the CSV file:

filename = 'img.csv'
line_number = 1
with open(filename, 'r') as f:
    mycsv = csv.reader(f)
    mycsv = list(mycsv)
    images = mycsv[line_number][0]
    titels = mycsv[line_number][1]
    tags = mycsv[line_number][2]
    descriptions = mycsv[line_number][3]
    colors = mycsv[line_number][4]
    
    
    for line in mycsv:
        driver.get('https://www.redbubble.com/portfolio/images/')
        time.sleep(3)
        
        #scroll down
        driver.execute_script("window.scrollTo(0,400)")


        #click color element
        color = driver.find_element(By.XPATH, "//div[@class='global-background-color-setting']//div[@class='sp-replacer sp-light']")
        color.click()

        #click element to write color code
        color = driver.find_element(By.XPATH, "//div[@class='sp-container sp-light sp-buttons-disabled sp-palette-buttons-disabled sp-palette-disabled']//input[@type='text']")
        color.click()
        color.clear()
        color.send_keys(colors)

        time.sleep(2)
        #click element to write title
        titel = driver.find_element(By.XPATH, "//input[@id='work_title_en']")
        titel.click()
        titel.clear()
        titel.send_keys(titels)


        time.sleep(1)
        #click element to write tag
        tag = driver.find_element(By.XPATH, "//textarea[@id='work_tag_field_en']")
        tag.click()
        tag.clear()
        tag.send_keys(tags)

        time.sleep(2)
        #click element to write descriptions
        description = driver.find_element(By.XPATH, "//textarea[@id='work_description_en']")
        description.click()
        description.clear()
        description.send_keys(descriptions)

        time.sleep(2)
        # Upload image
        upload = "//input[@id='select-image-base']"
        upload = driver.find_element("xpath",(upload))
        #file path specified with send_keys
        time.sleep(2)
        upload.send_keys(images)

Answer №1

attempt images = mycsv[line_number][0: row numbers limit]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to scrape using Python Beautiful Soup only when the text matches?

I am currently learning how to use beautiful soup by watching videos and trying examples. However, I am facing a challenge where the examples have well-structured HTML layouts and do not search for specific words anywhere. What I want to achieve is to prin ...

Error message encountered while trying to read and convert OHLC data using pandas in Python: AttributeError - 'int' object does not support attribute 'to_pydatetime'

I'm attempting to import OHLCV data from a .CSV file into a Pandas dataframe using the pandas.read_csv() function, but I keep encountering the same error and I can't determine the cause. AttributeError: 'int' object has no attribute &a ...

Encountering the error message "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" while using Django and Vue on my website

While working on my project that combines Vue and Django, I encountered a persistent error message when running the code: "Failed to load resource: the server responded with a status of 500 (Internal Server Error) 127.0.0.1:8000/api/v1/products/winter/yel ...

Is the commented out cron task in GAE being executed?

Recently, I was involved in a project that hosts its application on GAE. During a late-night deployment to the QA server (also on GAE), a cron job in the cron.yaml file was commented out. To my surprise, the cron task ran as soon as the deployment was com ...

What is the best way to display integers in a single string with spaces in between using Python?

I have created a Python function that takes two arguments - "Genome" and "Pattern" as strings. The function determines when the pattern matches the genome, it saves the starting index of the match in a list. However, I need to modify the function so that i ...

Achieving validation for individual items in Python step by step

I have a program that is functioning properly, but I need it to validate after each number input rather than at the end. How can I modify it to check after each number while maintaining separate functions for each task? Whenever I try to return a number ...

Telebot (pyTelegramBotAPI): the art of pausing for a solitary response while halting the bot

I am currently working on setting up a Python function to send messages via a Telegram bot, wait for a single reply, and then stop the bot to return the response. Although the code I have functions correctly initially, upon multiple calls, it seems to re ...

Preventing program continuation when KeyboardInterrupt occurs with multiprocessing.Pool in Python

Similar Question: Handling Keyboard Interrupts in Python's Multiprocessing Pool The multiprocessing module in Python includes a feature known as Pool, which can be found at http://docs.python.org/library/multiprocessing.html#module-multiprocessin ...

What is the best way to modify my if statement to avoid output duplication in my outfile?

When testing for a key, I either do a json.dump if it's present or add it if it's not. Additionally, I check for two other keys and add them if they are absent. I have nested these secondary tests. The issue with the current code is that if the ...

Updating Legacy pos() Methods in Qt

My app is a simple piano keyboard that receives midi and displays which keys are being pressed. It has a frameless window that I can move around using the left mouse button. The following code is functioning properly: def mousePressEvent(self,e): mo ...

Is there a way to organize the report directories within the Selenium-Cucumber Maven framework?

In my Selenium - Cucumber Maven framework setup, I have successfully implemented code to generate report logs for each run. However, I am facing an issue where the report folders created do not appear in sorted order. Is there a method or solution availabl ...

Running Python code within Postgresql database

Is it possible to run text that is stored in a Postgresql database as Python code and have it update the database accordingly? ...

The problem with importing a pre-defined Selenium function in the browser

Initial Set-up Working with selenium, I found myself constantly redefining functions. To streamline the process, I decided to create a separate file for these functions and import them as needed in my work files. A Basic Example Initially, when all fun ...

Exploring solutions for table counter in Web Crawler using Selenium and Webdriver

I have a question regarding web crawling and specifically targeting the hkgolden website. I utilized Selenium and WebDriver (Chromedriver) to create this web crawler. My current goal is to determine the number of tables located at: https://forumd.hkgold ...

Error: The 'KMeans' object does not contain the attribute 'k'

Although a similar question was raised [here], the solution provided did not work for me. In fact, another user commented on the answer, stating that it was incorrect. Despite this, the original poster (who also answered their own question) has not respond ...

Having difficulty selecting a radio button situated in a separate frame

I've encountered an issue while attempting to click on a radio button that is located in a different frame than the parent frame. Even though there are no exceptions thrown when executing the code provided below, the button itself does not get clicked ...

Executing a command on a website by utilizing Selenium with Python

I tried searching by class name but had no luck: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC button_loc ...

Something went wrong while attempting to decode JSON in Python due to a missing comma delimiter

How can I send JSON data using sockets in Python? {"receiver": "2", "sender:": 1, "seq_num": 10, "data": "{"iv": "jdjhvwGriJ95kZwgDWlShw==", "ciphertext": "Fg7ugYYAn ...

Looking to optimize your Python code by efficiently eliminating reversed duplicates from a list within a list and saving

Within my nested structure, I have millions of lists (currently using tuples). In each list, an element can only appear once. Initially, I believed that all lists were unique and necessary. However, I recently discovered that my nested list contains pairs ...

Implementing Threading in Python/Thread Execution

As a beginner, I've set out to create my first threaded script which will eventually function as a web scraper with improved speed compared to my previous linear scraping script. Despite hours of research and tinkering with example code, I'm stil ...