python txt file data processing data processing

data:

 

 Txt file for data processing:

= txt_file_path "basic_info.txt" 
write_txt_file_path = "basic_info1.txt" 
DEF write_txt_file (): 
    IF os.path.exists (txt_file_path) IS False: 
        return 
    with Open (txt_file_path, 'R & lt') AS r_file: 
        for Row in r_file: 
            List row.split = ( "\ T") 
            # Print ( "\\ t divided by the result line: {}." the format (List)) 
            # Print ( "be segmented columns: {}". format (list [2 ])) 
            COL = List [2] 
            RES = COL [2: -2] .split ( '|') 
            . # Print ( "this column segmentation result: {}" the format (RES)) 
            # divided result written in the new file 
            with Open (write_txt_file_path, 'a') AS w_file: 
                w_file.write ( ''.join(res))
                w_file.write('\n')'.join(res))
            #break

if __name__ == "__main__":
    write_txt_file()

  

Guess you like

Origin www.cnblogs.com/jiaxinwei/p/11704561.html