User Profile

Collapse

Profile Sidebar

Collapse
mari2025
mari2025
Last Activity: May 24 '13, 12:32 PM
Joined: Apr 2 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • how to count the number of lines in one text file and create a function of that?

    Dear friends,
    I would like to make a function in which I can count the number of lines in some text files and finally sum up these numbers. I would be thankful if somebody guide me how to do it in python?
    See more | Go to post

  • mari2025
    replied to add new field(column) to a file
    thank you very much for your helpful guidance. I would like to ask another question. I am going to apply the above code for many files those are in one folder. in your view, what is the fastest approach, I was thinking I should create a function or is there any other methods for to do it as quick as possible?
    See more | Go to post

    Leave a comment:


  • mari2025
    replied to add new field(column) to a file
    I have changed your code a bit and now it shows what I really want:
    Code:
    data = open("E:/SAGA/data/325125404.all","r").readlines()
    output = ["%s\t%s" %(item.strip(),1) for item in data]
    f = open("E:/SAGA/data/325125404_mod.all","w")
    f.write("\n".join(output))
    f.close()
    but still I am not sure that no where I have introduced the new column type...
    See more | Go to post
    Last edited by Rabbit; Apr 2 '13, 05:48 PM. Reason: Please use code tags when posting code.

    Leave a comment:


  • mari2025
    replied to add new field(column) to a file
    I also have question about "%s,", does not it use for the strings? as the 1 and 2 are numbers, should I use integer?
    See more | Go to post

    Leave a comment:


  • mari2025
    replied to add new field(column) to a file
    thank you very much for your prompt reply.
    I tried it and works. Moreover,
    if I want to add the new column using space between the new and the others what should I do?
    See more | Go to post

    Leave a comment:


  • mari2025
    started a topic add new field(column) to a file

    add new field(column) to a file

    Hello,
    I am beginner in Python and I need your guidance about the task I am given. I have to read a laser data file in python and then add two new columns to the data and fill them with specific integer values. I was able to read the file but was not successful in adding the new columns.I would be happy if you can kindly help me with it.
    Code:
    f = file("E:/SAGA/data/325125404.all", "r")
    >>> f.read()
    ...
    See more | Go to post
    Last edited by bvdet; Apr 2 '13, 02:35 PM. Reason: Please use code tags when posting code [code]....[/code]
No activity results to display
Show More
Working...