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

Reading and writing variables from CSV file in Python (Selenium)

$
0
0

I'm having some difficulties with my code - wondering if anyone could help me as to where I'm going wrong.

The general syntax of the goal I'm trying to achieve is:

  1. Get user input
  2. Split input into individual variables
  3. Write variables (amend) to 'data.csv'
  4. Read variables from newly amended 'data.csv'
  5. Add variables to list
  6. If variable 1 <= length of list, #run some code
  7. If variable 2 <= length of list, #run some code

Here is my python code:

from selenium import webdriver
import time
import csv

x = raw_input("Enter numbers separated by a space")
integers = [[int(i)] for i in x.split()]

with open("data.csv", "a") as f:
   writer = csv.writer(f)
   writer.writerows(integers)

with open('data.csv', 'r') as f:
   file_contents = f.read()
   previous_FONs = file_contents.split('')

if list.count(integers[i]) == 1:
   #run some code

elif list.count(integers[i]) == 2:
   #run some code

The error message I'm receiving is TypeError: count() takes exactly one argument (0 given)


Viewing all articles
Browse latest Browse all 98893

Trending Articles



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