Write to file doesnt work “Indentation error” [duplicate]

Write to file doesnt work "Indentation error" [duplicate]

This question already has an answer here:

I tried to save some data to a csv file and i got this error:

i:GamesPokemon GOpokeminer-0.2>python worker.py -st 10Traceback (most recent call last):  File "worker.py", line 25, in     import db  File "i:GamesPokemon GOpokeminer-0.2db.py", line 64    f = open('i:GamesPokemon GOpokeminer-0.2spawn_location.csv','w')                                                                       ^IndentationError: unindent does not match any outer indentation level

And this is the code:

def add_sighting(session, spawn_id, pokemon):  obj = Sighting(      pokemon_id=pokemon['id'],      spawn_id=spawn_id,      expire_timestamp=pokemon['disappear_time'],      normalized_timestamp=normalize_timestamp(pokemon['disappear_time']),      lat=pokemon['lat'],      lon=pokemon['lng'],  )  # Check if there isn't the same entry already  existing = session.query(Sighting)       .filter(Sighting.pokemon_id == obj.pokemon_id)       .filter(Sighting.spawn_id == obj.spawn_id)       .filter(Sighting.expire_timestamp > obj.expire_timestamp - 10)       .filter(Sighting.expire_timestamp < obj.expire_timestamp + 10)       .filter(Sighting.lat == obj.lat)       .filter(Sighting.lon == obj.lon)       .first()   if existing:      return  session.add(obj) f = open('i:GamesPokemon GOpokeminer-0.2spawn_location.csv','w')    f.write(pokemon_id+lon+lat+expire_timestamp)    f.close()    

This code is not mine, i’m just trying to make it write some details to a csv file. Can you please help me out with this, to make it work?

See on Reddit

Leave a Reply