Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
excel - json
#13
(Feb-28-2021, 10:54 AM)buran Wrote: line 13 of your code is
 sheet["CE"] = "vl"    
import json
from collections import namedtuple

from openpyxl import Workbook
from openpyxl.utils import column_index_from_string

Cell = namedtuple('Cell', 'row column value')

def search_for_value(data, lookup_value):
    for row, values in data.items():
        for column, cell_value in values.items():
            if cell_value == lookup_value:
                yield Cell(row, column, cell_value)


num = 50
OFFSET = 5
spam = "your JSON string here"
data = json.loads(spam)
for cell in search_for_value(data, num):
    print(cell)
    ws.cell(row=int(cell.row), column=column_index_from_string(cell.column)+OFFSET, value=cell.value)
    wb.save(filename="aexa_append.xlsx")
Reply


Messages In This Thread
excel - json - by jmabrito - Feb-26-2021, 06:32 PM
RE: excel - json - by buran - Feb-26-2021, 07:48 PM
RE: excel - json - by jmabrito - Feb-27-2021, 06:31 PM
RE: excel - json - by buran - Feb-27-2021, 07:43 PM
RE: excel - json - by jmabrito - Feb-27-2021, 10:51 PM
RE: excel - json - by jmabrito - Feb-27-2021, 11:02 PM
RE: excel - json - by buran - Feb-28-2021, 06:05 AM
RE: excel - json - by jmabrito - Feb-28-2021, 10:47 AM
RE: excel - json - by jmabrito - Feb-28-2021, 11:07 AM
RE: excel - json - by buran - Feb-28-2021, 10:54 AM
RE: excel - json - by jmabrito - Feb-28-2021, 03:29 PM
RE: excel - json - by jmabrito - Feb-28-2021, 03:30 PM
RE: excel - json - by jmabrito - Feb-28-2021, 11:15 AM
RE: excel - json - by buran - Feb-28-2021, 12:06 PM
RE: excel - json - by buran - Feb-28-2021, 03:31 PM
RE: excel - json - by jmabrito - Feb-28-2021, 03:41 PM
RE: excel - json - by buran - Feb-28-2021, 03:47 PM
RE: excel - json - by jmabrito - Feb-28-2021, 11:12 PM
RE: excel - json - by buran - Mar-01-2021, 06:09 AM
RE: excel - json - by jmabrito - Mar-01-2021, 08:04 PM
RE: excel - json - by buran - Mar-01-2021, 08:21 PM
RE: excel - json - by jmabrito - Mar-01-2021, 09:39 PM
RE: excel - json - by jmabrito - Mar-01-2021, 08:23 PM
RE: excel - json - by jmabrito - Mar-02-2021, 10:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting cells in excel to JSON format desmondtay 4 1,808 May-23-2022, 10:31 AM
Last Post: Larz60+
  [split] Print JSON Dictionary to Excel? venukommu 1 2,337 Nov-15-2019, 09:33 PM
Last Post: micseydel
  Nested json to excel using python unknown 1 4,486 Jun-13-2019, 05:40 AM
Last Post: buran
  Print JSON Dictionary to Excel? SimpleGuy 6 14,534 Aug-18-2017, 01:05 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020