python


Detecting a change in a CSV row


I am trying to find a way to detect when string elements in csv file change values. When the value changes, I want the operation of the program to change. I want to read the value in the for loop one step ahead and compare it to the current value. Unfortunately my research has only turn up results that step the for loop ahead by one rather than simply reading the value.
Any help would be appropriated.
import csv
with open("bleh.csv", "r") as bleh:
blehFileReader = csv.reader(bleh, delimiter=',')
next(blehFileReader, None)
for row in blehFileReader:
name = row
nextname = next(blehFileReader)
print(name)
if name != nextname:
print ("name has changed")
Instead of looking at the next name, look at the previous one:
previous_name = None
for row in blehFileReader:
if row != previous_name:
print ("name has changed")
....
previous_name = row

Related Links

import mxnet dmlc error Entry add_n already registered under different entry
How to open and execute kill task code through html
how do I remove unwanted empty dimension from xarray DataArray (squeeze doesn't work)
How to do math expression from input() in Python?
opening luigi.LocalTarget in binary read mode (decoding error)
GPU slows way down after a few loops
Google's verify_id_token function not working
ImportError: libgomp.so.1: cannot open shared object file: No such file or directory
Django Iterating through an object set with unique_together and no pk
Can i deploy a Django project using Apache that is not located in /var/www?
How to run a python script on images present in firebase?
dictionary variable formatting in Python's Mysqldb
How to see print output from generator before ending the cycle?
Python script- need help understanding this while loop [closed]
Reset weights of a pretrained incetion_v3 model in Tensorflow
Trying to connect to FTP site but getting wrong SSL version number error?

Categories

HOME
sql-server-2008
laravel-5
ajax
cntk
cil
pug
signalr
angular-cli
rotation
angular2-routing
translation
cpu-architecture
chaiscript
couchdb-2.0
heap-memory
sbt-assembly
rfc
bro
constructor
google-shopping
automata
squarespace
jcl
google-api-java-client
prestodb
primes
cruisecontrol.net
csh
tampermonkey
osmdroid
excel-2013
metadata-extractor
system.data.sqlite
websauna
getjson
rowcount
oracle-xml-db
preg-grep
large-data
honeysql
shibboleth
exiftool
ical-dotnet
control-flow-graph
amazon-clouddrive
walmart-electrode
livefyre
azureportal
rhel6
rollback
windows-95
vst
rstudio-server
ruby-2.0
instruments
windows-nt
asynccallback
web-essentials
plone-3.x
persistence.xml
jta
function-fitting
vips
mirrorlink
kendo-menu
textkit
achartengine
criteria-api
lines-of-code
uos
word-2013
pgagent
gyroscope-framework
docopt
funq
eclipse-classpath
argument-passing
neoload
phpdocx
uipickerviewcontroller
sslexception
vmware-server
zend-lucene
sunspot-rails
macruby
die
jpf
emacs23
handwriting
cookieless
drawtext
hardware-acceleration

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App