csv.vim icon indicating copy to clipboard operation
csv.vim copied to clipboard

Run script over every cell

Open jukhamil opened this issue 4 years ago • 1 comments
trafficstars

Is there a way to run a script over every cell in a column with this plugin?

For example, a script which takes a value in a cell, sends it as a parameter to a REST API using the Python Requests library, converts the JSON response to a list by using Requests' .json() method, and finally accesses values of that list with a list index and inputs those entries into a different cell?

jukhamil avatar Aug 17 '21 17:08 jukhamil

copying here the content of my mail. (Please do in future not double post):

Hi, what you want to do, is a bit tricky. Currently, there is no builtin functionality for calling a function for each cell in a column, also this shouldn't be too hard. You can already retrieve a certain column in a register. I think the easiest would be to copy a column into a register and push that to a python script, that iterates over each line and calls the API. However, not sure how to handle the result.

BTW: Vim does not have a builtin way to call a REST API, although there exist plugins like https://github.com/diepm/vim-rest-console JSON can be parsed using the builtin json functions.

Thanks, Christian

chrisbra avatar Aug 30 '21 13:08 chrisbra