I have a function that is set up to write to a database with 10-20 standard variables with 10 fields each, but the application is going to a place where database access is not available. Can Mathematica read an Excel file and pick up the portions of the file that relate to one of these 20 variables, change them if needed and write the whole thing back again? If so, how would that be accomplished? Thanks!
$\begingroup$
$\endgroup$
10
-
1$\begingroup$ Yes. See reference.wolfram.com/mathematica/guide/… You could keep each "table" in a separate Excel file or de-normalize the entire database and store it in a single file. You could also just store everything in CSV. $\endgroup$– JagraCommented Jun 18, 2012 at 22:29
-
6$\begingroup$ Beware of where you are going ... Excel is not transactional, not multiuser, not robust, ... it is NOT a DB $\endgroup$– Dr. belisariusCommented Jun 18, 2012 at 22:37
-
$\begingroup$ @belisarius Totally agree. I was trying for a read it all in and write it all out type of solution. No transactions available. $\endgroup$– NothingtoseehereCommented Jun 18, 2012 at 22:55
-
1$\begingroup$ There is a way to manipulate Excel like you would with VBA: mathematica.stackexchange.com/questions/4594/… $\endgroup$– faysouCommented Jun 19, 2012 at 6:14
-
2$\begingroup$ It's probably much better to go with a real database. Having said that, perhaps you could use Leonid's SQL DSL as a starting point and just operate on mathematica lists, which you could export to a file. $\endgroup$– AjasjaCommented Jun 19, 2012 at 8:06
|
Show 5 more comments
1 Answer
$\begingroup$
$\endgroup$
1
According to the comments you have several options:
- Use
Import
andExport
to work with Excel files (noted: this is not straightforward with problems mentioned in the comments). - Use this answer to manipulate the Excel file like it is done in VB.
- Using Leonid's SQL DSL as a way to get database like syntax while keeping all the data in Mathematica lists.
I would also like to add that Mathematica comes with a built in, standalone, database called HSQL. Wherever Mathematica exists that database also exists and I wonder if perhaps you missed this when you said that you cannot use databases where this code is going. There is an example of how to set up an HSQL database as well as many example queries here.
-
$\begingroup$ I was not aware of this! Thanks very much for your answer! $\endgroup$ Commented Jan 12, 2014 at 19:32