User Profile

Collapse

Profile Sidebar

Collapse
scharnisto
scharnisto
Last Activity: Dec 14 '10, 12:41 AM
Joined: Dec 2 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • i figured it out. the following code, does what i need to do.

    Code:
    orig_file = open (input(), "r")
    lines = orig_file.readlines()
     
    start = False
    saved_list = []
    for rec in lines:
        if "count" in rec:
            start = True
        if "Volume" in rec:
            start= False
        if not start:
            saved_list.append(rec) 
     
    new_text_file
    ...
    See more | Go to post

    Leave a comment:


  • the last code would work. thank you dwblas!
    i have it like this now:

    Code:
    orig_file = open (input(), "r")
    lines = orig_file.readlines()
    
    start = False
    saved_list = []
    for rec in lines:
        if "count" in rec:
            start = True
        if not start:
            saved_list.append(rec)
        if "Volume" in rec:
            start= False
    ...
    See more | Go to post

    Leave a comment:


  • How to delete lines between two words from text file?

    Hi,

    i need a script, that deletes all the lines between two certain words in a text file. the two words appear several times in the text file.

    i have a code, that works so far. the problem is, once it looped for the first time through the text file, the end_word appears before the new start_word. so i have to tell the program, to start searching for the end_word, after the start_word.

    here is the code....
    See more | Go to post

  • scharnisto
    replied to How To Delete Line(s)
    if you still have it, could you please post the code?
    See more | Go to post

    Leave a comment:


  • well, i do have the full list.
    i want to loop through the list.

    i make up an example. i want to do something with all the green fruits in there:

    Code:
    fruit_list = ['greenapples', 'blueapples', 'greenpears', 'bluepears', 'greenoranges', 'blueoranges']
    
    for green* in fruit_list:
    but it does not work, because i need to loop for the full value like greenapples.
    and i am looking for a way to...
    See more | Go to post

    Leave a comment:


  • well i can not traverse the list, because i just know parts of the value. in order to traverse, you need to have the exact list element value, right?

    so i need a different way. any suggestions?
    See more | Go to post

    Leave a comment:


  • okay thanks bvdet. my problem is, that i just know parts of my list element, for which i am looping.

    so i tried to work my way around it, with this code:
    Code:
    orig_file = open ("*Strata1CombinedAll.txt", "r")
    lines = orig_file.readlines()
    
    
    
    
    import fnmatch
    def find(seq, pattern):
        pattern = pattern.lower()
        for i, n in enumerate(seq):
            if fnmatch.fnmatch(n.lower(),
    ...
    See more | Go to post

    Leave a comment:


  • can't assign to literal ERROR, looping through list

    hi,

    i am trying to get this to work. it works fine so far. only when i try to loop through the list, i get an error.
    any suggestions?


    Code:
    orig_file = open ("*Strata1CombinedAll.txt", "r")
    lines = orig_file.readlines()
    
    
    
    
    import fnmatch
    def find(seq, pattern):
        pattern = pattern.lower()
        for i, n in enumerate(seq):
    ...
    See more | Go to post
No activity results to display
Show More
Working...