User Profile

Collapse

Profile Sidebar

Collapse
nishi2rock
nishi2rock
Last Activity: Nov 8 '08, 08:40 PM
Joined: Nov 8 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • nishi2rock
    replied to compare string
    If your problem is about reading from and into files...

    FileObj = open(Filename,m ode) eg:f = open("tmp.txt", "w")

    read and readlines can be used to read data from file
    eg: FileData = f.read() reads all the data of file into FileData

    write and writelines can be used to write

    coming to your string manipulations

    someString = 'A string'

    ...
    See more | Go to post

    Leave a comment:


  • nishi2rock
    replied to os.path pathname manipulations
    I could not exactly understand your problem.
    According to my understanding you dont want the whole Filepath to be printed on the console.

    Try this code

    Code:
    Curdir = os.getcwd()
    
    for DirInfo in os.walk(Curdir):
        for File in DirInfo[2]:
           print (DirInfo[0]+"\\"+File).replace(Curdir,"")
    See more | Go to post

    Leave a comment:


  • if all you want is to make another xml ( still a text file ) dont bother that it is xml and u can use just file operations to make the xml file.

    Code:
    TxtFileData = [aLine.strip() for aLine in open('data.txt').readlines()]
    
    while "" in TxtFileData: TxtFileData.remove("")
    ## To remove any line in between if there is no data
    
    XmlData = """
    <people>
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...