audreyt / ethercalc

Node.js port of Multi-user SocialCalc
https://ethercalc.net
Other
2.97k stars 538 forks source link

Import from SocialCalc? #721

Closed twothreenine closed 4 years ago

twothreenine commented 4 years ago

Sorry for this question, I'm probably missing something simple. I'm trying to write a Python script that duplicates an ethercalc sheet into another sheet, using this python wrapper around ethercalc API. When executed, the ethercalc page shows me every single line from the socialcalc save as an error message "unkown command" (after being refreshed)

test_sheet = ethercalc.EtherCalc("https://ethercalc.org").export("2g15x60fbv6l", format="socialcalc")
print(test_sheet)
new_sheet_host = ethercalc.EtherCalc("https://ethercalc.org")
new_sheet_host.create(test_sheet, format="socialcalc", id="3g15x60fbv6l")
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ethercalc.org:443
DEBUG:urllib3.connectionpool:https://ethercalc.org:443 "GET /_/2g15x60fbv6l HTTP/1.1" 200 None
socialcalc:version:1.0
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave
--SocialCalcSpreadsheetControlSave
Content-type: text/plain; charset=UTF-8

# SocialCalc Spreadsheet Control Save
version:1.0
part:sheet
part:edit
part:audit
--SocialCalcSpreadsheetControlSave
Content-type: text/plain; charset=UTF-8

version:1.5
cell:A1:t:Test
cell:A2:t:This is a  test
col:A:w:119
sheet:c:1:r:2:tvf:1
valueformat:1:text-wiki
--SocialCalcSpreadsheetControlSave
Content-type: text/plain; charset=UTF-8

version:1.0
rowpane:0:1:1
colpane:0:1:1
ecell:A1
--SocialCalcSpreadsheetControlSave
Content-type: text/plain; charset=UTF-8

--SocialCalcSpreadsheetControlSave--

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ethercalc.org:443
DEBUG:urllib3.connectionpool:https://ethercalc.org:443 "POST /_/3g15x60fbv6l HTTP/1.1" 202 755

Zwischenablage03 (followed by all the remaining lines of the socialcalc save)

Is the ethercalc-python API outdated, is it an error within ethercalc.org or am I making a simple mistake here?

eddyparkinson commented 4 years ago

Python script import/export

should the data include the sheet name?

It looks to use create here: https://github.com/audreyt/ethercalc/blob/master/API.md

you should be able to test this directly from the command line.

new_sheet_host.create(test_sheet, format="socialcalc", id="3g15x60fbv6l")

should test_sheet include the sheet name? i.e. it wants a json { "room": "test" , "snapshot": "..." }

Note there have been a lot of problems with import because of changes to https://github.com/SheetJS/sheetjs

Duplicate sheet

form will auto duplicate a sheet

http://sheet.cellmaster.com.au/exampleform/form

I don't know if it helps.

twothreenine commented 4 years ago

Thanks for the reply, but the opposite seems to be the case. I could make it work by using the update function instead of create and replacing lines 122:127 in @joequant 's python wrapper by return self.put(sid, data, "text/x-socialcalc")

eddyparkinson commented 4 years ago

Glad you found a solution. There looks to be a shortage of example in here: https://github.com/joequant/ethercalc-python/tree/master/examples

This makes it hard understand correct usage.

I will close this, let us know if you want more help.