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

Why does pandas multi-index dataframe slicing seem inconsistent?
How to restore a tensorflow network and to use it
Python swampy installation error
How to save a csv file so iPython shell can open and use it?
Combine tuples of tuples if share some elements
Inheritance in Python: What's wrong with my code?
Confusing reference ownership: how to properly deallocate (via Py_DECREF) objects of an object?
Insert element to list based on previous and next elements
Why is str.strip() so much faster than str.strip(' ')?
How to make nosetests use dotted syntax?
Slice column in panda database and averaging results
How to implement cumulative distribution function using interval alpha, beta and X in Python?
Error: “The process 'xxx' not found” occurs after executing parallel python code
How do I replace a character in a string that repeats many times with a different character in python?
Python ODEINT is passed non-zero y'' but returns zero y' and y
Executing VBAscript from Python

Categories

HOME
laravel-5
app-inventor
puzzle
mapping
windows-7
facebook-graph-api
puppet
visualization
flyway
ll
tizen-wearable-sdk
triggers
octopus-deploy
public-key-encryption
automata
x-frame-options
lenskit
ejs
plupload
pycrypto
koa
embedly
apple-tv
thingsboard
spring-ws
source-maps
azure-servicebus-queues
bootstrap-typeahead
geopandas
codelite
classpath
positioning
encase
rowcount
getline
swiftcharts
shibboleth
redhat-datavirt
rhel.net
readfile
code-behind
mongoexport
agent
polyfills
socketscan
dart-pub
html-agility-pack
email-parsing
spell-checking
atlassian-crowd
coremidi
mix
linkageerror
gemini
distribute
mfc-feature-pack
qt-linguist
sonarqube5.3
site-prism
pyopengl
c++-actor-framework
livechat
jstat
docopt
dalekjs
emma
picat
delphi-xe3
visualstatemanager
cilk-plus
nsmatrix
client-side-scripting
fileconveyor
sametime
gdataxml
crocodoc
socketstream
text-services-framework
msgbox
datamember
audiostreamer
plinq
dirty-data
castle-validators
data-execution-prevention





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android


MS Developer
developer works
python
ios
c
html
jquery


RDBMS discuss