Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6222125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:15:34+00:00 2026-05-24T08:15:34+00:00

I am not a very good coder. But I really want to automate something

  • 0

I am not a very good coder. But I really want to automate something I have to do at work. Basically, I have a bunch of placemarkers in google earth showing hand-holes of a municipal fiber network. I have a few pictures of each hand-hole that I want to place as a tag in the .kml file. Basically, I want to have it so when they click on a placemarker in google earth, it brings up the little description bubble and shows the pictures for each hand-hole and probably some other vital info.

Right now I have each hand hole labeled as either TO-. So hand-hole number 101 has a TO-101. And I have already made a script that has renamed all the pictures to match the name. So, if hand hole TO-101 has 3 pictures, they would be TO-101-1.jpg, TO-101-2.jpg, TO-101-3.jpg.

So, basically, I am trying to make a python script that reads the kml file (which I have done succesfully). I need it to find the corresponding TO-101 or whichever handhole in the .kml file, add a line below that line that reads:

<description> <img src="TO-101-1.jpg"><img src="TO-101-2.jpg"></description>. 

Need to do this for about 5000 pictures and 2000 or so hand-holes.

I have tried to this:

import string, glob, sys, os, fileinput
f = open('./hand-holes.kml','r')

while f:
line = f.readline()
if line == "<name>TO-101</name>":
print line

And I can’t even get it to find and print that line. I know the line is in the file, and I know the path is right. Because if I comment out the if line == “TO-101” it displays the contents of the file. So, if I can’t even get that to work, there is no chance I am going to get the rest of it to work. I have tried looking at several pieces of search and replace type python example code. Some of it uses a string library, which I am not sure if I need to use.

Can anyone help me? Thanks

Renosis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:15:35+00:00Added an answer on May 24, 2026 at 8:15 am

    I’m assuming the reason your if line == "<name>TO-101</name>" line doesn’t work is because it probably has whitespace preceding it. If you changed it to line.strip() == … then it would presumably work.

    Your best bet would be to implement an XML handler to read in the existing file, parse it, and add the new section. Start maybe with xml.sax

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have some experience with programming but I'm not very good with pointers.
I am not very good with Regex but I am learning. I would like
I'm not very good in SQL and HQL... I have two domains: class Hotel
I'm not very good at PHP and would like to have a PHP function
I'm not very good at regex but maybe there's a simple way to achieve
I'm not very good with terminology.. here's the code I have: enum { LoggerLogNone
I'm not very good at C, and I always get stuck on simple string
I'm not very good with Django's form . Here is Order from models.py class
I'm not familiar at all with JQuery and I'm not very good with CSS,
I've been working with asp.net MVC and am still not very good at it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.