Trying to write a program for my CXii CAS that will open a text file on the calculator and read data from it, do various string operations, hopefully store results in a different file. I've downloaded the "Student Software" for my PC and the Python interpreter works as I'd expect (think "Hello, world.").

But when I try to open a file with f = open('file.txt') on the emulator I get "ValueError: Unsupported use of open". Is this just something you can't do on the TI implementation, have I forgotten an import or something? I can't find any example Nspire Python programs online that do this kind of thing, otherwise I'm sure the lightbulb would have come on Sad
Indeed, you can't do that, just like in Nspire-Lua or TI-Basic, in fact.
But you can import data from TI-Basic variables that you may have pre-populated.
Adriweb wrote:
Indeed, you can't do that, just like in Nspire-Lua or TI-Basic, in fact.
But you can import data from TI-Basic variables that you may have pre-populated.


Thank you so much for the lightning-fast reply! That's a shame Sad but won't stop me working on the project. I've done a couple of tests to see how easy (or not!) it will be to solve my task by 'brute force', and it seems that the limit for a single string in this environment is 64k. For the file I'd like to work on, that's still <100 'chunks', so do-able (especially if I use a friendlier environment to create the string chunks).

That still leaves me with the challenge of how to store the output of the processing, but I'm assuming I can use native Python structures (e.g. lists etc), or - a lot more learning needed here! - calculator data structures, and that I can make them persist somehow (?in the .tns file? ?in an NSpire document). I'm thinking that some of the programs I've seen for processing sensor data will probably give me a steer for that part...
I actually don't remember if they provide a function to store data back... maybe ?
Check out their documentation for their module ti_system, that's where it would be
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement