python - Copying a range of columns from a text file and creating a new file -


I'm new to Python and I'm parsing some data for some sonar files, for which I need to process more information. I have received this code and I am trying to manipulate it to fulfill my goal. I only need the information of the first 53 columns, the previous 100+ column external data is not required. In line for f: if line.strip ():

  f = open ("ADV125cm.txt", "r") g = open "ADV125cm_fixed.txt", "w") G.write ("\ t" .joined (line split (0,53) [1:]) + "\ n") F.close () g.close ()  

I have received this error code and I do not know what it means:

Type error: Expected one character buffer object

Any help

You get typeError: a character buffer object is expected

/ Code> because string is expected Sorting characters you are going through 0, 53 Maybe you are confused with piece operation If you want to get 53 of the first row columns , then you need the line [: 53] . To implement this change your for loop code is created: in line for f: if line.strip (): g.write (" However, if you want to be the first and the last white space with the characters 53 < Em> column , the code can be redone in such a way:

  for line f: g.write (line.strip () [: 53] + ' \ N ')  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -