# Character that indicates a newline in a long text field

**URL:** <https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256>\
**Category:** Formulas\
**Created:** [November 5, 2024, 10:21am UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256 "2024-11-05T10:21:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitar.tuparov](https://forum.seatable.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@dimitar.tuparov](https://forum.seatable.com/u/dimitar.tuparov)\
**Post date:** [November 5, 2024, 10:21am UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256/1 "2024-11-05T10:21:29Z")

</div>

I want to find the location of the character that indicates a newline in a long text field.  
I am trying to use the formula find(findString, sourceString, startPosition), but i don’t know which symbol to look for.  
Is this possible? My goal is to find a way to extract the information from the second row into a separate column.

 ![Screenshot_1](https://forum.seatable.io/uploads/default/original/2X/0/0482ba8da213428627e71c9d74803e18032b2900.png)

---

<div class="post-metadata">

**Author:** ![daniel.pan](https://forum.seatable.com/user_avatar/forum.seatable.com/daniel.pan/32/13_2.png) [@daniel.pan](https://forum.seatable.com/u/daniel.pan)\
**Post date:** [November 6, 2024, 1:48am UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256/2 "2024-11-06T01:48:19Z")

</div>

The string formula cannot work with long text field.

The long text field is in Markdown format. A possible solution is to write a Python script to parse the content and extract the second line.

Here is an example:

```Python
from seatable_api import Base, context
import json

# Initialize SeaTable connection
server_url = context.server_url or "https://cloud.seatable.io"
api_token = context.api_token
base = Base(api_token, server_url)
base.auth()

# Get table name from context
table_name = "My table"

def parse_second_line():

    # Get all rows from the table
    rows = base.list_rows(table_name)
    
    # Process each row
    for row in rows:
        # Get the content from content_to_parse column
        content = row.get('content_to_parse', '')
        
        # Split the content into lines and get the second line
        # If there's no second line, use empty string
        lines = content.split('\n')
        second_line = lines[1].strip() if len(lines) > 1 else ''
        
        # Update the row with parsed content
        row_id = row['_id']
        base.update_row(table_name, row_id, {
            'parsed_content': second_line
        })

parse_second_line()

```

---

<div class="post-metadata">

**Author:** ![dimitar.tuparov](https://forum.seatable.com/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@dimitar.tuparov](https://forum.seatable.com/u/dimitar.tuparov)\
**Post date:** [November 6, 2024, 4:34pm UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256/3 "2024-11-06T16:34:33Z")

</div>

Daniel, thank you so much! ♥ I’m not a programmer and had no idea about Python scripts - but I was able to implement your code and it works great! Seatable is the most awesome software company I have ever seen!  
I’ve only slightly customized it by adding a 1 second timeout (with little help from ChatGPT) - because I have over 1000 rows and I’ve hit server limits. This is the final version of the code:

```auto
from seatable_api import Base, context
import json
import time

# Initialize SeaTable connection
server_url = "https://cloud.seatable.io"
api_token = " ************************************************"
base = Base(api_token, server_url)
base.auth()

# Get table name from context
table_name = "My table"

def parse_second_line():
    # Get all rows from the table
    rows = base.list_rows(table_name)
    
    # Process each row
    for row in rows:
        # Get the content from content_to_parse column
        content = row.get('content_to_parse', '')
        
        # Split the content into lines and get the second line
        lines = content.split('\n')
        second_line = lines[1].strip() if len(lines) > 1 else ''
        
        # Update the row with parsed content
        row_id = row['_id']
        base.update_row(table_name, row_id, {'parsed_content': second_line})
        
        # Add a delay to avoid hitting rate limits
        time.sleep(1)

# Call the function
parse_second_line()

```

---

<div class="post-metadata">

**Author:** ![daniel.pan](https://forum.seatable.com/user_avatar/forum.seatable.com/daniel.pan/32/13_2.png) [@daniel.pan](https://forum.seatable.com/u/daniel.pan)\
**Post date:** [November 7, 2024, 12:18am UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256/4 "2024-11-07T00:18:28Z")

</div>

> [@dimitar.tuparov](#):
>
> I’ve only slightly customized it by adding a 1 second timeout (with little help from ChatGPT)

Glad to hear. ChatGPT is a great helper to non programmers.

---

<div class="post-metadata">

**Author:** ![system](https://forum.seatable.com/uploads/default/original/1X/04603423fe81a46c321283663086c475429e8ccb.png) [@system](https://forum.seatable.com/u/system)\
**Post date:** [November 9, 2024, 12:18am UTC](https://forum.seatable.com/t/character-that-indicates-a-newline-in-a-long-text-field/5256/5 "2024-11-09T00:18:59Z")

</div>

Closed on November 9, 2024, 12:18am UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
