Copying excel data into a python list in IPython using clipboard?

前端 未结 3 2113
广开言路
广开言路 2021-02-14 04:06

Is there a way to perform the following workflow:

  1. Select cells in an Excel spreadsheet
  2. Copy them using Ctrl+C
  3. Get the content the selected cells
3条回答
  •  生来不讨喜
    2021-02-14 04:45

    Here is what I usually do:

    1: get a csv file

    Copy-paste the cells you want into a new Excel document. Click 'File' then 'Save as'. Select 'Save as type: CSV' . Close Excel and open the file with notepad or other editor.

    Now you have something like this:

    1, 2, 3
    4, 5, 6
    

    2: get a python list

    You can either

    • use csv to load your csv file; or
    • use the search/replace functionality of your editor to replace start/end of lines with '[' and ']' then copy paste to ipython.

提交回复
热议问题