chrisbra / csv.vim

A Filetype plugin for csv files
http://www.vim.org/scripts/script.php?script_id=2830
Vim License
1.28k stars 62 forks source link

Run script over every cell #198

Closed jukhamil closed 1 year ago

jukhamil commented 3 years ago

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?

chrisbra commented 3 years ago

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