Splitting a column by a delimiter

Hi there everyone,

i have zipped csv data which i am unzipping with a go lambda function. The first column of my csv data has several infos like: ProjectNumber_Project_City_Country. For me the question now would be if there is some similar solution like with python to split these entries via the delimiter:

df[[ 'ProjectNumber' , 'Project' , 'City' , 'Country' ]] = df[ 'Column1' ]. str .split( '_' ,expand = True )


to get four seperated columns instead of one. Would really look forward if anyone got any clue how i can solve this problem.

Greetings and have a nice week

I’m pretty sure, there’ll be something in the strings package to Split() a string.

Morning Nobbz,

thx i will take a look. And post the result afterwards. :slight_smile:

When parsing CSVs, it’s always good to rely on a library that knows how to deal with csv.
How do you know your delimiter won’t be present on the line as a simple member of the Project’s name, for instance ?

I recommend using the default csv package - encoding/csv - pkg.go.dev package.
Create a reader on your input, and use reader.Read() to get a record (that’ll be properly split).

1 Like

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