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

  • SEARCH
  • Home
  • 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 8825325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:51:05+00:00 2026-06-14T06:51:05+00:00

1.Getting buildid from a buildlocation which is the last word after \ which is

  • 0

1.Getting buildid from a buildlocation which is the last word after “\” which is “A1234ABCDE120083.1” in this case

2.After getting the buildid,am opening a file and then trying to match the line “Engr Label: Data_CRM_PL_177999” to get the label name which is “Data_CRM_PL_177999”

3.Final output should be “Data_CRM_PL_177999”

For some reason I am getting the following syntax error..

 import re

 Buildlocation= '\\umor\locations455\INT\A1234ABCDE120083.1'

 Labelgetbuildlabel(Buildlocation)

def getbuildlabel(BuildLocation):
buildid=BuildLocation.split('\')[-1]
Notes=os.path.join(BuildLocation,Buildid + '_notes.txt')
if os.path.exists(Notes):
    try:
        open(Notes)
    except IOError as er:
        pass
    else:
        for i in Notes.splitlines:
        if i.find(Engr Label)
            label=i.split(:)[-1]

print label//output should be Data_CRM_PL_177999

Output should be:-

Line looks like below in the file
Engr Label: Data_CRM_PL_177999

SYNTAX ERROR

 buildid=BuildLocation.split('\')[-1]
                                   ^
 SyntaxError: EOL while scanning string literal
  • 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-06-14T06:51:06+00:00Added an answer on June 14, 2026 at 6:51 am

    In the line

    buildid=BuildLocation.split('\')[-1]
    

    The backslash is actually escaping the following quotation mark
    So, Python thinks this is actually your string:

    '[-1])
    

    Instead, you should do the following:

    buildid=BuildLocation.split('\\')[-1]
    

    And Python will interpret your string to be

    \\
    

    Interestingly, StackOverflow’s syntax highlighter hints at this issue. If you look at your code, it treats everything after that first slash as part of the string, all the way to the end of your code sample.

    You also have a few other issues in your code, so I tried cleaning it up a bit for you. (However, I don’t have a copy of the file, so obviously, I wasn’t able to test this)

    import re
    import os.path
    
    build_location= r'\\umor\locations455\INT\A1234ABCDE120083.1'
    
    
    label = get_build_label(build_location)
    
    # Python prefers function and variable names to be all lowercase with
    # underscore separating words.
    def get_build_label(build_location):
        build_id = build_location.split('\\')[-1]
        notes_path = os.path.join(build_location, build_id + '_notes.txt')
        # notes_path is the filename (a string)
        try:
            with open(notes_path) as notes:
                # The 'with' keyword will automatically open and close
                # the file for you
                for line in notes:
                    if line.find('Engr Label'):
                        label = line.split(':')[-1]
                        return label
        except IOError:
            # No need to do 'os.path.exists' since notes_path doesn't
            # exist, then the IOError exception will be raised.
            pass
    print label
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this error: Invalid option file options on trying to invoke Astyle via C#
Getting ERR_CONNECTION_RESET after more or less 2 minutes of uploading a rather big file
I am getting an error using this query select dbresultsid, TestCase, BuildID, Analyzed, Verdict,
Getting this error when I follow the simple code example from jsoncpp, that basically
Getting this error while I am trying to run /compile/build a Proiject Incompatible Types
GETTING THIS ERROR WHEN UPLOADING A FILE : LoadError (no such file to load
Getting extremely confused with an adminhtml module i'm trying to write! Effectively I have
Getting 401 errors when trying to use ASP.NET back end in load balanced environment
Getting 'Dispatcher has no subscribers' error while trying to post message to a channel
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using

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.