I'm a beginner of python prog language and have a file which has an
output similar to the below:
|---------------------------------------------|--------------------|
|ID |Name |
|---------------------------------------------|--------------------|
|129147032122-1103152530110-00216-1024424668 |suckboss.West|
|129147032122-1105123486137-28635-1355202588 |whatever.Central|
|129147032122-1103152583056-00412-0852863243 |peterpan.East|
|-------------------------------------------------------------------|
Is there a way to read an entire column in the file (i.e, name column)?
Thx,
-Chris
Not that I know of, but you can split the text on lines and then on
columns. Something like (session on ipython):
In [2]: print a
|---------------------------------------------|--------------------|
|ID |Name |
|---------------------------------------------|--------------------|
|129147032122-1103152530110-00216-1024424668 |suckboss.West|
|129147032122-1105123486137-28635-1355202588 |whatever.Central|
|129147032122-1103152583056-00412-0852863243 |peterpan.East|
|-------------------------------------------------------------------|
In [3]: [i.split('|')[2] for i in a.split('\n')]
Out[3]:
['--------------------',
'Name ',
'--------------------',
'suckboss.West',
'whatever.Central',
'peterpan.East',
'']