Skip to content

Split a Column by a Delimiter

A store list has a location field such as EU|Paris, and you want separate region and city columns. Split Column cuts the text at a delimiter and writes the pieces, in order, into the columns you name.

You'll use: File Input → Split Column → File Output.

  1. 1Input
    File Input
    stores.csv
  2. 2Transform
    Split Column
    location · | → region, city
  3. 3Output
    File Output
    stores_split

Sample data

Save this as stores.csv. Store S3 has no city, S4 has no location, and S5 has a third piece.

csv
store_id,location
S1,EU|Paris
S2,US|Boston
S3,EU
S4,
S5,US|Austin|TX

Steps

  1. On Datasets, upload stores.csv.
  2. In a new flow, add File Input. Set File type to CSV and Dataset to stores.csv.
  3. Add Split Column and set:
    • Column: location.
    • Split by: Delimiter.
    • Delimiter: click Pipe, or type |.
    • New columns: region, city. The first piece goes into the first name, the second piece into the second.
    • Leave Keep the original column checked, so you can compare each result with its source.
  4. Add File Output. Set File type to CSV (.csv) and Dataset name to stores_split. Connect the nodes in order and click Run.

Prefer to describe it?

With a provider key set up, upload the sample data, open a blank flow in the same project and ask the Flow assistant, for example: "split the location column on | into region and city." Review the proposed nodes and settings, then choose Apply and save. We ran this prompt on the sample data; see what the assistant built. Its flow can differ from the steps above in node order and names, so check each setting. The assistant never runs a flow, so click Run yourself.

Result

store_idlocationregioncity
S1EU|ParisEUParis
S2US|BostonUSBoston
S3EUEUnull
S4nullnullnull
S5US|Austin|TXUSAustin

Split Column fills region and city with the pieces in order: EU has no second piece, so city is null; US|Austin|TX has a third piece with no column, so TX is dropped

Check the result

Save the flow, click Preview, select the Split Column node and click Run preview. S1 should show EU and Paris. If region holds the whole EU|Paris, the delimiter does not match the data, for example a comma instead of a pipe.

Pitfalls

  • Extra pieces are dropped. TX in US|Austin|TX has no column, so it is not in the output. Add a third name to New columns to keep it, and keep the original column to spot such rows.
  • Missing pieces become null. S3 gets a null city rather than an error, so check for nulls before you rely on the new column.
  • Spaces stay. EU | Paris gives "EU " and " Paris". Add a String Transform with Strip spaces on each new column.
  • Choose a delimiter that only separates. Splitting people's names on a space breaks names with several words.
  • For one row per piece instead of one column per piece, use Split to Rows.

Exported Python

Click Export in the editor toolbar. The pandas and polars tabs show this code for the flow. It reads stores.csv from the script's folder and writes stores_split.csv.

python
import pandas as pd

df_stores = pd.read_csv('stores.csv')
_parts = df_stores['location'].astype('string').str.split('|', expand=True)
df_stores = df_stores.assign(region=(_parts[0] if 0 in _parts.columns else pd.NA), city=(_parts[1] if 1 in _parts.columns else pd.NA))
df_stores.to_csv('stores_split.csv', index=False)

See also