Extract a column from text file - Python -


i'm beginner py.

i need extract contents of column 12 huge flat text file every time word found within text file (similar awk '{print $12}' in bash) in python script.

so far have (example, not real code):

word = a_word a_word in data:    column12 = data.split()    print(column12[11]) 

i assumed should start counting 0 opposed 1, though may incorrect.

also, for loop correct type of code?

thanks!

loop on open file object:

with open('somefile') infile:     line in infile:         print(line.split()[11]) 

so, yes, use for loop , use 0-based indexing.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -