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

Extract subarray from collection of 2D coordinates?
tkinter populate treeview using threading pool
How to make a function determining the winner of Tic-Tac-Toe more concise
Django update model entry using form fails
ctypes using HRESULT(python)
How to export property values with django-import-export
Plotting Coordinate Lines Using Matplotlib
BASH - Summarising information present in 2 genotype data columns in one column (ped file) [closed]
Python 3: How to call function from another file and pass arguments to that function ?
Streaming mp3 files in Django through Nginx
Opening PE file with Bokken
Python exercise: last letter / first letter
Python/Pygame: Can you run a program whilst having a Pygame window that can still update?
Replacing values in array from netCDF
confused about Python list syntax
Object orientated function parameter to alter variables

Categories

HOME
ember.js
admin-on-rest
vhdl
google-contacts
boost-thread
steam
reportportal
apollo
webdav
terrain
file-io
codeblocks
slim-3
shipping
facebook-javascript-sdk
x11
dryioc
gwtp
arm-template
pyephem
jpeg2000
zoho
styles
embedly
nsmenuitem
tcpclient
data-cleansing
opencart2.3
onesignal
nesc
idl
shapes
google-drive-realtime-api
nsurlconnection
windows-10-iot-core
pox
pace
.net-assembly
swagger-editor
issue-tracking
poco-libraries
topic-modeling
magiczoomplus
bayesian-networks
viewgroup
jupyter-console
bids
encapsulation
openweathermap
istorage
infinite-scroll
gmt
polar-coordinates
gulp-typescript
objloader
ebtables
vst
visible
gherkin
dbscan
asp.net-mvc-partialview
inet
mfc-feature-pack
lemoon
android-viewholder
rad
p-np
textkit
ubercart
lines-of-code
xaml-designer
robocode
magento-1.12
tilestache
moai
pgagent
proximity
sysctl
cocoascript
grunt-express
ogr2ogr
dto
data-generation
dvcs
dynamic-proxy
facebook-chat
modeshape
astyanax
installshield-2009
execvp
vmware-server
mailcore
fraud-prevention
arbor.js
pstree
applicationcontext
path-manipulation
fileutils
nsindexpath
ihttphandler
symbol-server
yajl
savestate
code-design
multibyte-functions
standardized
dotproject
rd

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