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

Pyinstaller will create an executable with --onefile, but not without it
PyMongo update multiple records with multiple data
How to automatically input ssh private key passphrase with pexpect
Extract only the portion of a string between two regex patterns
Filtering dictionary keys by a function of their associated values
webrtc without a browser
Simple python IF statement not working?
Python: aliased to python3
replacing certain expressions in file but only one time
why recompile python after lib devels installed?
Unable to scrape google news accurately
How to optimize factorization code in Python?
How do I represent this FOR loop in Python?
Assigning the reference of one object to a variable does not work in a python script but works in command line
Reading UTF8 Encoded File in PyCharm
Urllib and saving multiple urls to different filenames

Categories

HOME
makefile
tensorflow
jdbc
answer-set-programming
tinyos
puzzle
oauth
amazon-swf
boost-thread
jasmine
jbehave
smartphone
command
h2
automated-tests
vlc
appmaker
i2c
google-spreadsheet-api
unity2d
game-physics
gwtp
activesync
multiple-monitors
uisplitviewcontroller
titan
r-lavaan
aspell
dendrogram
mousewheel
jive
scalaz7
apple-tv
url.action
jenkins-job-dsl
dd-wrt
jackson-dataformat-csv
svnkit
read-write
edb
getline
data-extraction
division
openpgp
precedence
openshift-enterprise
mongoexport
html-agility-pack
openweathermap
estimation
double-buffering
tuleap
udev
photon-controller
onresume
manifest.mf
spoofing
com-interop
spring-lemon
mfc-feature-pack
axes
xmp
license-key
intellitest
datasnap
ytplayerview
graphical-logo
gray-code
gulp-livereload
google-hadoop
low-level
ticket-system
pgagent
proximity
ember-components
jstat
ghostdoc
libssh2
funkload
codeigniter-a3m
mbox
help-viewer
openkinect
bsod
wic
sim900
opendata
gamepad
osx-snow-leopard
vmware-server
cbcentralmanager
git-filter-branch
returnurl
autostart
xgettext
cadisplaylink
subtract
file-exists
selectmanycheckbox
ou
tcxgrid
qtembedded
testunit
dcpu-16
junit3
nvelocity
rijndael
recordset
quick-search
communicationexception
swfloader
weborb
hardware-infrastructure





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