Skip to main content

Hey everyone,

I would like to share a custom Zapier integration I built to solve a few problems. The integration provides the following action steps. I hope you find it helpful. :)

---

Run JavaScript Code: This is kind of a clone of the regular Code Step. Nothing fancy, it just comes with some useful tools available in the global scope. It also supports modern JavaScript async/await.

The global scope includes the following utilities:

  • moment: The well-known moment.js library that helps when dealing with date/time.
  • _: Lodash library that makes it easier to work with objects and arrays.
  • JSON: this replaces the built-in JSON.parse function with the more advanced JSON5 library.
  • toCSV: A function that converts an object to CSV.

 

---

Export to CSV: This action makes it easy to convert JSON data or line items to a CSV string or file.

 

---

If you’re interested in trying it, here’s the invite link: https://zapier.com/developer/public-invite/112461/039174f595539444ce5c14e114c1dc1e/

 

Known issues:

  • The code field in Run JavaScript Code action doesn’t highlight code.

Feel free to report any other issues and let me know if you there’s any other library that you wish you could use in a Code Step.

Awesome work @ikbelkirasan


Hi @ikbelkirasan!

Got a question, maybe you can help.

I use “Export to CSV” and “Input Type: Line Items”. I have around 50 line items and get a 400 error when testing with data that contains danish characters (æ,ø,å) in keys and values. Can you imagine a way I can get through with this? 

Weirdly, if I test with just a few line items containing danish characters, I get no errors. 

 


This tool is great, thank you so much!


Is it possible to rename the file being generated?  Currently it’s coming through as “output.csv” but ideally, I’d like this filename to be unique and contain the current day’s date.


Thanks for creating this brilliant tool @ikbelkirasan!


Hi @ikbelkirasan -  I accepted in the invite using the link (https://zapier.com/developer/public-invite/112461/039174f595539444ce5c14e114c1dc1e/), but I’m still not able to build the zap / access the “Advanced Utilities” options. Is there maybe a new(er) invite link I should be using? Thank you so much! 😀


Hi @qbftech - The link still works. Maybe you need to refresh your zap editor page to access the integration. Make sure to select it in an action step.


Hi @qbftech - The link still works. Maybe you need to refresh your zap editor page to access the integration. Make sure to select it in an action step.

I with the same Problem, maybe something is wrong


Hey there, I gave this a shot and the invite it still live, @Yago Almeida!

You’ll need to accept the invite and perhaps give it a minute and/or do a hard refresh of the editor. It’s worth mentioning this app will only be visible as an action step.

I hope some of this helps! 🧡


Hi, @ikbelkirasan!   I am new to Zapier and trying to convert a JSON file on my google drive to a CSV file and found your integration.  Yet when I select the file name mFile: (exists but not shown)] for the ‘*JSON data’ field from the previous google drive step and test it, I keep getting:  JSON5: invalid character 'h' at 1:1.  Am I not able to pull a file in from my google drive or do I need a URL of where the file is?  Thanks for any guidance.


Thanks @ikbelkirasan this is soooo useful!

I think the CSV export utility skips over empty line items in the input which is sub-optimal because it leads to variability in the number of columns, and the column order. Is there any way you could add an option to preserve empty columns?


I’m a bit confused on the CSV file output. I’m trying to save line items as a csv.
When I run the test, it generates:

hydrate|||.eJwtjcuSgjAURP8la3nGB7gaZKTEEYtSUXRjRYiAJoRKgqCW_z444-7Wud19niBhpcSlPMp7hcEY-KAHilJIVCb4WKQdcarKMMz-0HAXvhP6X6YKVaNLJbWQjNYC87-cZY8GlmX1AEoSVneDH2ha5rAHzgUm6bFE9O1I8e14LgjuRq4N4pkA4yf4-D-cYpmztz2_pxxJxoWaYemKm_f_P9Vl2h1dr-bkHZOyEmNNe6CqwFzpDMp7SagCqoiiBytRI9SEUS0hhVIRJM-MU82wR9DQ9NB9RE14qnkQjnB4WFSrYDYTMr80a_8S5di5BBYMo7O70zetsoXtNLcNQvtti2uow_uVzkoUy8XcimU0LWoyiSFeOmb_EHr6Nt6Im2O1VRNv-6jj0_1gnXIf_Uy3p3a5vyiBiE5ePHfnq-WsmBCTHla-t8-UzN5Nblgm3zYZHEwnh-wKXq_XL-kkkHY:1rNGhW:-u8PEAyW0sOKuT6tSinhsb5JkrQ|||hydrate

I’ve no idea what this is/means/does. I’m just looking for a simple way to save some data into a csv file.


@guillermo I know I’m about 2 years late but I found a solution to my own issue with the MalformedPOSTRequest error when trying to convert a JSON string to CSV here

In a Javascript code step you need to take your JSON string and run a gnarly replace() function on it to get rid of bad characters. As soon as I did this, the CSV converter happily accepted my JSON.

jsonString.replace(/c\x80-\uffff]/g, (m) => `%${m.charCodeAt(0).toString(16).padStart(2, '0')}`)

Is there a limit to the amount of rows in the csv?


@PhilT72 

Perhaps check out the Files by Zapier Zap app: https://zapier.com/apps/files-by-zapier/integrations#triggers-and-actions


Reply