Python: reduce some column in TXT by regexp
Dear all, I try to read TXT file, change the lines and write a result in a new TXT file but the delimiter is "" how I could find \t""\t""\t""\t and replace with \t""\t with open( dat, "r", encoding="ANSI" ) as infile: with open( outdat, 'w' ) as outfile: line=infile.readline() cnt=1 while line: print( "Line {}: {}".format( cnt, line.strip() ) ) line=infile.readline() # ---------------------------------- # here I try to find and replace, but do not working # re.findall(r"^\d",line): # ---------------------------------- cnt+=1 outfile.write(line) outfile.close() infile.close() My sourse like that: "" "" "" "" "" "" "Interval: 01/01/17 00:00:00 - 31/01/17 23:59:59" "" "" "" "" "" "" "" "" "" "" "Trunk: 1" "" "" "" "" "" "" "End date/time" "" "Duration" "Phone number" "Ext." "" "" "Pin" "Pulses" "Raw charge" "Charge" "Type" "" "Trunk group: 1" "" "" "" "" "" "" "" "" "" "" "" "Circuit: 1" "" "" "" "" "" "" "" "" "" "" "03/01/17 11:04:00" "" "49s" "052648227" "331" "" "" "" "0" "$0.1222" "$0.1467" "7" "03/01/17 16:33:00" "" "5m,7s" "0899331694#" "339" "" "" "" "0" "$1.0643" "$1.2771" "7"