I’m struggling with a bit of a challenge. I have an API that is returning a text string in CSV format. I am then storing that text string as a single text. My goal is to then parse that string into the Bubble Database.
My thinking is to somehow create a CSV file from that csv formatted text, store the file to the database, and then use the “import CSV” action to parse that file. The import part works great, but the part I can’t seem to figure out is how to Create a CSV from that string and store it to the database (without the user having to download and then upload it).
Does any one have any thoughts on how to do this? (Or thoughts on a better way to parse and store the CSV text string.)
You could save the csv string as text field. Then schedule an api workflow. Then create that backend workflow to have key values to match every field it will need but add another field that is a list of texts and pass the csv text field split by (whatever splits each entry) and add conditional if the list of things count > 0 the run the same workflow again and make the list the same minus the item added to the database.
Hi @williamtisdale -
Thanks for this! Is there any chance you might be able to break this down a bit more for me? I’m not quite sure I understand how to implement this. Thank you and Sorry for my ignorance!
My CSV String is basically just 4 columns and then an undefined number of rows:
Group #,Group Name,Group Location,Group Description
Example #,Example Name,Example Location,Example Description
Example #,Example Name,Example Location,Example Description
Yea, no. Don’t do that suggestion. There’s a native bubble operator you can use to split the string by ‘,’ and then refer to them as a number which is 0 based.
Hi @doug.burden -
Any chance you can elaborate a bit? I tried to do this using the split by , operator but the issue is the some of the cells contain commas (inside quotes, as standard for csv when the cell contains a comma), but bubble doesn’t ignore these commas. Additionally the “split by ,” functionality doesn’t recognize “new lines” as a comma and therefore doesn’t trigger a split. Any guidance on how to handle this.
Thank you!
I created a regex code to match all of the line breaks and all the commas (that aren’t inside quotes) with a unique symbol that would never organically appear in my CSV file (for me I used “}}}”)
I then split all the text by that symbol, and passed this list of texts to the backend. The backend then takes items 5-9 and makes them into a thing (items 1 thru 4 are the headers and I dont need those), it then increments a those number by 4 and repeats until there are no more item in the list.