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.
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:
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()
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:
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()
Glad to hear. ChatGPT is a great helper to non programmers.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.