Friday, October 22, 2021

#1 2021-10-05 12:13:31 pm

Vijay_Yukthi
Member
Registered: 2021-04-16
Posts: 34

Convert excel data into json

Hi All,

Hope all are doing good. In applescript, if it possible to convert the excel file data(2 columns) into JSON file and to read the JSON file?

Offline

 

#2 2021-10-07 07:31:41 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 511

Re: Convert excel data into json

It's certainly possible, but I think it will take a little coding, it's not just some built-in command.

Excel has an Applescript dictionary, so you can read the values with Applescript.

You can translate between Applescript Records and JSON with ASObjC or with the free App Store application "JSON Helper."

You can find the code for the ASObjC method in this thread:
https://www.macscripter.net/viewtopic.php?pid=191475

So I'd read the values, then use Applescript to put those values into a record however you need them, then convert to JSON with one of the above methods.

However, I don't know what your data looks like. Say you've got two columns, one with a key, the next with a corresponding value. Applescript doesn't like using variables to create keys for records. It can be done with metascripting. Or it might be easier, if it's simple JSON that's required, to just build proper JSON format out of your data with Applescript text manipulation, and skip making a record and converting it with an automatic tool.

If you provide a sample spreadsheet, it may be easier for us to see what's involved. However, probably few users here have Excel, so the reading Excel part you may need to figure out for yourself.


Ditched the Hackintosh.
Intel Mac Mini i7 and M1 Mac Mini on a KVM.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)