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

Python subprocess.Popen and stdin: No such file or directory
Python: Include complete package in another package
How to optimize a black box function in Python?
Track download progress of S3 file using boto3 and callbacks
Remove elements of one list from another list using “while”
Hosting Bokeh Server with Tornado on AWS
Functions that help to understand json(dict) structure
Scapy How converting hex to new packet
Write and read test files in dictionary format
Python 3.x Connect to account with request POST
AttributeError: module 'networkx' has no attribute 'Graph'
How to exclude selected domains from python crawl script in google search
Python - Py2exe error
Anaconda import packages from another environment
How to Drag & Drop Multiple rows of a QTableView in pyqt5
Handle prompts in Python - popen

Categories

HOME
vue.js
reverse-engineering
puzzle
vb6
angular-cli
ncurses
wxwidgets
google-sheets-api
chaiscript
wampserver
ios10
simpy
dropbox
x11
game-maker-studio-1.4
public-key-encryption
mongodb-query
activesync
aspell
bar-chart
cairo
session-timeout
sql-update
iup
rworldmap
croppic
katharsis
osmdroid
aurelia-binding
helix-3d-toolkit
expand
nsurlconnection
jquery-cycle2
redhat-datavirt
es-shell
issue-tracking
tic-tac-toe
infusionsoft
twiki
common.logging
wcf-security
tango
pdftk
intersystems-ensemble
fastq
fqdn
chunked-encoding
windows-firewall
slidesjs
tcserver
photography
addin-express
gmt
iron.io
shinyjs
icefaces
cron-task
scalar
amf
interactive-brokers
java.util.calendar
code-readability
lmfit
ipojo
mogrify
findcontrol
guzzle6
stackframe
hg-git
tilestache
grunt-contrib-concat
sthttprequest
eclipse-classpath
sgml
visualstatemanager
factors
circos
wic
dynamic-binding
ienumerator
lame
qss
gdataxml
marmalade-edk
sequelpro
couchdb-lucene
continuous-testing
getstring
concurrent-programming
law-of-demeter
selectonemenu
serp
qtembedded
nagle
zend-form-element
loadui
recordset
trampolines
webrat
usability-testing
divx
cots

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