I've written a swift app that outputs an array of strings.
I would like to import this array into a python script for further processing into an excel file via xlsxwriter, I would like to do this as an argument.
My array looks like this:
[["1", "12:32", "Harry\'s\na wizard", "", ""], ["2", "12:34", "Harry reads a sign:", "Sign:", "\"You're a wizard Harry\""]]
I'd like to pass this into python verbatim, so I can process it into an excel table. The output is a human readable file.
I've tried adding my array into PyChars's "Modify Run Configuration...", then processing it via:
import sys
arr = sys.argv[1]
print(arr)
but I get: [[1,
I try to add the argument as """argument""", but I get: [[1, 12:32, Harry's\na
I try as: f"""argument""", but get: f[[1, 12:32, Harry's\na
f'argument' results in: f'[[1,
I try reading the argument with:
arr = ast.literal_eval(sys.argv)
but I get several errors ending in: "ValueError: malformed node or string: ..."
arr = ast.literal_eval(sys.argv[1])
gives me: return compile(source, filename, mode, flags, File "", line 1 [[1, ^ SyntaxError: unexpected EOF while parsing
I've solved this problem by exporting the array to a JSON file from my swift app and importing it in the python script, but I'd really like to know if there's any way of passing it as a command line argument.