mtkilic
mtkilic

Reputation: 1243

How to Run Javascript code from Python pandas? Convert to csv method

I have been working Python pandas DF. I usually Load a csv files, but at the same time I have excel files too. I find out pandas is very slow reading Excel files. I have JavaScript code that will convert from excel to csv. I am looking to way calling this script to automating conversion to csv to speed the pipeline. Basically do conversion behind scene. What is the best way to do this? I can share JS code anytime.

Upvotes: 0

Views: 786

Answers (2)

mtkilic
mtkilic

Reputation: 1243

I follow subprocess method and it worked perfectly for me. Here is what I added to my code, order to run javascript code from python.

Import subprocess
subprocess.check_call(["cscript", "yourjsfile.js"])

Upvotes: 0

hpaulj
hpaulj

Reputation: 231395

start node app from python script explains how to use python subprocess to run a node.js script.

node.js runs javascript code on a v8 (chrome) engine. It's is easy to install on both Linux and Windows. There's an active SO tag, https://stackoverflow.com/questions/tagged/node.js

I like coffeescript as a way of writing javascript code with a syntax that is much more like Python.

I've see Python web stack questions (e.g. django) that talk about running javascript, though that might be on the client side rather than the serve.

Upvotes: 1

Related Questions