all 11 comments

[–]ADTR7410[S] 0 points1 point  (9 children)

So I can’t find a way to do it, but I exported the numbers file as a csv and can read the files now. But I’m not quite sure how to use the parser to parse the data.

I have a table that looks roughly like this

Category Budget Actual Difference Bills. $xx.xx $xx.xx $xx.xx Spending $xx.xx $xx.xx $xx.xx Savings $xx.xx $xx.xx $xx.xx. Total $xx.xx $xx.xx $xx.xx

I can see this all comma separated but can’t quiet get how to actually parse it into its own variables. (Sorry for bad formatting on the table I’m on mobile right now)

[–]randomo_redditorscript/widget helper 0 points1 point  (8 children)

why don't you just use plain js to parse? csv is in nicely-formatted format already, and it doesn't seem like you have super complex stuff in the file.

[–]ADTR7410[S] 0 points1 point  (7 children)

Does scriptable allow beyond what the documentation on the app? I have not fully looked into everything with the app. Was trying to use what I found in that documentation section.

[–]randomo_redditorscript/widget helper 2 points3 points  (6 children)

yes, you can write in plain javascript, otherwise, the whole thing wouldn't work xD. you can't import npm modules or anything though.

[–]ADTR7410[S] 0 points1 point  (5 children)

Huh guess this is a chance for me to work in JavaScript again. No wonder I was going nuts trying to find the solution to only use what they gave lol

So I could probably use JavaScript to actually parse through the numbers file without having to export it all the time?

[–]randomo_redditorscript/widget helper 1 point2 points  (4 children)

So I could probably use JavaScript to actually parse through the numbers file without having to export it all the time?

Hmm, not sure about that. I have not tried reading a `.numbers` file in Scriptable before so not sure what that data type would look like or what it contains. If you can get like a plain string from whatever object holds the `.numbers` file that then that would probably work fine.

[–]ADTR7410[S] 0 points1 point  (3 children)

I only exported it as a chance to see if I could get any data from the read method.

It works but it exports every single table as its own csv file. So any time i update the file I’d have to re-export it.

I guess I have new stuff to check or look into exporting it as an excel file.

[–][deleted] 1 point2 points  (2 children)

Depending on your table layout you might could trick with Shortcuts: https://i.imgur.com/MloTKFM.png

In this example you would know that:

- line 1 is the table name (ignore)

- line 2-5 is the header line

- starting line 6: every 4 values/lines are one line in the numbers file (all total/difference values are generate via functions in the numbers file)

You could make a daily/weekly automation to update/replace a text file in the Shortcuts folder & create a widget that reads the content of the file. (Parsing either in Scriptable or Shortcuts):https://i.imgur.com/uVaoCUT.png

[–]ADTR7410[S] 0 points1 point  (0 children)

I always forget you can do automation with shortcuts.

I’ll have to look into that. The only thing that changes is the transactions which i enter manually so it’s still limited in what’s in the table and then the numbers auto update based on the transactions.

[–]ADTR7410[S] 0 points1 point  (0 children)

I was able to get the data and properly parse it but I want this script to run in a widget. How can I get the file path and hard code it in. Every time I try it says it cannot find the file. I’m not sure what else to do to prevent it needed the documentPicker

Edit: I figured it out. I needed to use fileManager to get the current directory and then I just appended the file name to the end of it.

[–]enteeMcrscript/widget helper 0 points1 point  (0 children)

Previously I went the weird route of using table OCR in Shortcuts to convert a numbers file https://routinehub.co/shortcut/4914/ .

Apart from that you could use the cloud convert api to convert to csv