python - Split txt file with open spaces -


i'm trying split text file in python following error:

valueerror: need more 1 value unpack 

my code:

for line in lines:     x, y, e, r, t=line.split()     return x, y, e, r, t 

the format of text file is

x y e r t 

but lines missing numbers or letters, example

 x   e r t  x y   r t 

so guess why error, can't find way resolve it. possible count blank spaces variable?

>>> 'x   e r t'.replace('  ', ' _').split(' ') ['x', '_', 'e', 'r', 't'] >>> 'x y   r t'.replace('  ', ' _').split(' ') ['x', 'y', '_', 'r', 't'] >>> 'x     r t'.replace('  ', ' _').split(' ') ['x', '_', '_', 'r', 't'] 

and check special value '_' signalizes missing value.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -