[Django]-Parse textarea line by line (or a specific line #) with Django

11👍

Use text_area_value.splitlines() instead. Then you don’t have to worry about \r\n or \n issues. Also, it reads better.

2👍

for line in text_area_value.split('\n'):
    # do something with line

or if you want a specific number (3 in this example – which is the 4th line, counting the “human” way):

lines = text_area_value.split('\n')
    # do something with lines[3]

Leave a comment