I am using the following to read a tab separated file .There are three columns in the file but the first column is being ignored when i print the column header only.how can i include the first column too
f = open("/tmp/data.txt")
for l in f.readlines():
print l.strip().split("\t")
break
f.close()
Output: ['session_id\t', '\tevent_id_concat']
The first column name is id where it s not printed in the above array
EDIT
print l yields the following
EDIT 1:
'id\tsession_id\tevent_id_concat\r\n'
Output: ['id\t', '\tevent_id_concat']
print lbefore yourprintstatement and show the output? P.S. Also, no need for.readlines()here, pretty much as always. - Lev Levitskycsvmodule will do the job. - Evgeny Lazinprint repr(l)? - poke'id\tsession_id\tevent_id_concat\r\n'.strip().split('\t')gives['id', 'session_id', 'event_id_concat']for me. Are you sure you show the actual code that's executed? - Lev Levitsky