Synthoid / ExportSheetData

Add-on for Google Sheets that allows sheets to be exported as JSON or XML.
MIT License
234 stars 46 forks source link

Error sidebar array separator character #134

Open tristanlabetoulle opened 3 years ago

tristanlabetoulle commented 3 years ago

The settings can be changed to set the separator not to a single character but the sidebar is limited juste to one character (problem for \n for example)

Synthoid commented 3 years ago

Ha, only took 24 hours for people to start experimenting with loading custom settings. The main challenge with assigning a newline char as the separator is telling the difference between the newline char \n (one char) and the string "\n" (two chars). Thinking about it while typing my comment, I may be able to switch to supporting multiple chars, basically separator strings instead of separator chars, then I can validate the input string and come up with a clever way to convert "\n" to \n (and other such char conversions like \t). I've mostly not been able to think of said solution for converting certain strings into special chars.

OhNoxius commented 3 years ago

or maybe use regex? I haven't seen your code, but maybe you can let users only type in characters in regex formatting, use JS String.replace() with a RegExp to convert all those different separators to 1 unique separator, and then use your existing code as before...

(I was just going to start a new request asking support for multiple separators, but then I saw this)

Synthoid commented 3 years ago

Do you mean multiple separator chars (ie ,, |, and % simultaneously) or allow for string separators (ie %%)?

Using RegEx to validate strings is a good idea for joining escaped syntax like "\n" into single chars like \n. Though it should currently be possible for users to create something like:

Test1,
Test2,
Test3

Which would emulate having \n as the separator.

OhNoxius commented 3 years ago

ah yes smart trick to have a newline as separator (I'd have to adjust a lot of spreadsheet cells though ;) I'm not sure what you mean exactly with your question, but I guess I mean the former: split the cell for every separator char that is encountered from a string, like ";:\n" => splits on ";" ":" and newlines