APIs & Integrations

Salvathor_Rojas
Member

How to correctly read the contents of a CSV file from python within a custom workflow code

Hello everyone

I'll briefly share the context of my problem:

1.- I have a HubSpot form that attaches a CSV file within a specific property of a contact.

2.- I have a workflow that starts its execution once said contact property has a known value.

3.- Within the workflow I define a custom code that attempts to do the following:

 

* Read and store the signed URL of the CSV file stored in the contact property. (I have no problem here)
* Through the signed URL of the CSV file and through a Python request, read the content of all rows of the CSV file. So that with the information of each row I can create a contact, through the HubSpot Contacts API.

 

4.- However, when reading the content of the file, it is not displayed correctly, and the information displayed in the console
refers to the fact that I have to log in to HubSpot.

 

How could I solve this? Any ideas, advice or suggestions?

Or rather: how can I correctly read the content of my CSV files through their signed URL?

 

Below is a screenshot of my code:

 

Captura de pantalla 2024-08-12 165424.png

 

Below is a screenshot of the console output when reading the CSV file:

 

Captura de pantalla 2024-08-12 172744.png

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

How to correctly read the contents of a CSV file from python within a custom workflow code

Hey, @Salvathor_Rojas 👋 Thanks for sharing your project. This definitely sounds like a tough one to solve. I don't have any Workflow documentation that shows this is supported as an action, and we'll leave this open in case any other community members have some feedback for you.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Salvathor_Rojas
Member

How to correctly read the contents of a CSV file from python within a custom workflow code

Hello @Jaycee_Lewis 

 

Thanks for read my question.

 

I haven't really found a way to read my CSV file within a custom code in workflows. At least as of today.

However, I have already managed to create several contacts through the HubSpot Imports API. That is, I import a local excel file with the data of several contacts, and through a request to the Imports API from Python, my contacts are created in the CRM.

It's not what I wanted, but it works.

 

Below I attach the link to the HubSpot documentation, where I took the example from.

 

https://developers.hubspot.com/beta-docs/guides/api/crm/imports

 

Kind regards.

0 Upvotes