Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
1  
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. –  Jagra Jun 18 '12 at 22:29
6  
Beware of where you are going ... Excel is not transactional, not multiuser, not robust, ... it is NOT a DB –  belisarius Jun 18 '12 at 22:37
    
@belisarius Totally agree. I was trying for a read it all in and write it all out type of solution. No transactions available. –  R Hall Jun 18 '12 at 22:55
1  
There is a way to manipulate Excel like you would with VBA: mathematica.stackexchange.com/questions/4594/… –  Faysal Aberkane Jun 19 '12 at 6:14
2  
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. –  Ajasja Jun 19 '12 at 8:06
show 5 more comments

1 Answer 1

up vote 3 down vote accepted

According to the comments you have several options:

  • Use Import and Export 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.

share|improve this answer
    
I was not aware of this! Thanks very much for your answer! –  R Hall Jan 12 at 19:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.