I need to export several matrices created in Stata to several different specifically named sheets of an already existing excel file. This would be a piece of cake in Matlab using xlswrite(). I am having trouble finding a similar command in Stata.
"xml_tab" would work but it doesn't seem to want to let me open and make changes to an already existing excel file. It always starts by creating a new excel file.
I would appreciate some help as to how I might get "xml_tab", or some other Stata command, to open an already existing excel file, make changes to it (overwriting specific sheets with new matrices), and then save it without overwriting all the other stuff on the other sheets that I don't want to touch.
Can Stata do that?
Thanks
EDIT:
An example of what I need to do is this:
*Define poverty line
scalar povlin=29347.5
*1) SETUP sheet
mat SETUP=(1,J(1,3,0),1,J(1,2,0),1,1,J(1,5,0),povlin)
/* Here I need to export the matrix SETUP to sheet "SETUP" in an
already existing excel file. In matlab it would be
xlswrite('filename','SETUP','A2') */
*2) FARM sheet
tabstat acres,stat(sum) save
mat acrtot=r(StatTotal)
tabstat aehh07 offrinc07,save
mat vmeans=r(StatTotal)
mat maehh=vmeans[1,1]
mat moffrinc=vmeans[1,2]
tabstat aehh07 offrinc07 acres,stat(cv) save
mat CV=r(StatTotal)
tabstat acres,save
mat macres=r(StatTotal)
mat FARM=(1,acrtot,maehh,CV[1,1],moffrinc,CV[1,2],moffrinc,CV[1,2],J(1,3,0),macres)
/* Here I need to export the matrix FARM to sheet "FARM" in the
same already existing excel file where I put the SETUP matrix. In matlab it would
be xlswrite('filename','FARM','A2') */
I need to do this kind of thing for several sheets.
By matrices you might mean (a) Mata matrices (b) Stata matrices (c) complete or partial datasets including one or more Stata variables. The last (c) seems most likely.
The way to change something in Excel is to open Excel. Stata does not offer as it were remote control of Excel manipulations, which you seem to be asking for. But the Stata commands import excel and export excel appear to offer alternatives.
I have never used xml_tab (Stata Journal 2008) but I always understood its main purpose to be export of results tables, not data.
If you mean (b), you can use svmat first.
I am guessing you don't mean (a).
(UPDATE July 2013) Stata 13 now has a putexcel command. See http://www.stata.com/help.cgi?putexcel for an introduction.
Related
I'm currently working on lattices. To solve some problems, I have to generate a big number of matrices of the same basis. This takes a lot of time. For example, to generate 10'000 bases, I have to launch the code when I go to bed and retrieve the list of basis in the morning. The problem is that I can't do it every day.
So I'd like to save my list of 1000 matrices once for all in a text file. The problem is that when I do it, I get strings.
The matrix list is named BB.
with open('yourfile.csv', 'w') as f1:
writefile = csv.writer(f1)
writefile.writerows(BB)
import csv
with open('yourfile.csv','rU') as f1:
data=list( csv.reader(f1) )
Do you know how I could find a way to save the matrix list and then, directly recover a list? I'm working on the Sage notebook.
The correct and easiest ways to save and load Sagemath objects via a file are
save(your_list_of_matrix, 'filename.sobj')
your_list_of_matrix = load('filename.sobj')
Saving Sagemath objects to CSV will need to convert the values into strings and will lose precision.
Refer to the official document for more detail.
How to write text to excel sheet specific column or row through CAPL scripting?
The content has to be written on already existing excel sheet on specific location
Only as a scheme for further discussion as CAPL is truly not the best solution to do this:
Step 1. Open your (text) file with openFileWrite()
Step 2. Find the place in text where you want to write,
how would you do this using CAPL?
Step 3. Write text with filePutString()
Step 4. Close file fileClose()
If it is really necessary to write something into .csv (in worst case into .xls) file during a measurement, than maybe you have to try using a C library instead of hacking CAPL.
There is no API for extending CAPL to work with Excel sheets. While you might write it yourself, it's probably easier to call some external script in Python (or any other language), which gets your data as arguments and place them into specified excel sheet.
You can execute it with sysExecCmd() function.
I trained my model in Nvidia Digits 5 and I would now like to extract the accuracy and loss plots that were generated during training for a report. Is this data saved somewhere so that it would possible to extract the data for these plots so that I could plot it in Python and perhaps ultimately modify the plots to compare different models etc?
The best solution I have found is to either look at the HTML file or to scan the text file caffe_output.log that is produced by Caffe. The text file is usually stored in /var/digits/jobs/insert_your_job_id/ but you can also just run on linux systems:
locate caffe_output.log
Go to your DIGITS job folder and locate your job's subfolder. Inside you'll find a file status.pickle, which is a pickled object containing all your job's information.
You can load it in python like so:
import digits
import pickle
data = pickle.load(open('status.pickle','rb'))
This object is somewhat generic and may contain multiple tasks. For a typical classification task it will likely be just one, but you will still need to access it via data.tasks[0]. From there you can grab the plots:
data.tasks[0].combined_graph_data()
which returns a somewhat convoluted dict (unfortunately - since your network can produce many accuracy/loss outputs, as well as even custom ones). It contains everything you need though - I managed to plot accuracy with:
plt.plot( data.tasks[0].combined_graph_data()['columns'][2][1:] )
but it's likely that you'll have to write a bit of custom code. As always, dir() is your friend.
I have created a certificate design with powerpoint.
Now I have to create 100+ copies of it... each with a different name (the recipent).
I was wondering if there was an easy way to do it...
I can have the list of names in excel or txt.
I am open to other ideas as well, like changing the slide into an images and batch processing it in a simple way
You may also try out SlideMight, a tool for merging hierarchical data with PowerPoint templates. SlideMight supports iteration over data, to generate slides or to populate tables. There is more functionality, but you don't seem to need that. SlideMight is in fact a coding system, like mail merge for Word is.
Input data format is at this time just JSON; you would need to convert your Excel sheets first, e.g. using this Excel to JSON add-in for Excel.
There are versions for Windows and Mac OS X.
More information is at www.SlideMight.com
Disclaimer:
I am the owner of Delftware Technology, the company that developed SlideMight.
And I am one of the developers.
This is a question that really belongs in SuperUser, not StackOverflow (which is intended for coding questions, not software how-to-use questions).
But ...
Save your names to a plain notepad TXT file, one name per line.
Start PowerPoint, choose File, Open and point to your TXT file (you may force the matter by choosing . in Files of type:
Apply whatever template you like to the result.
I have a commercial add-in that'll do this and quite a bit more, but from your description, you don't need it.
I have a wellformatted excel file with a lot of macros and styling in it that I want to keep.
Then i have this information I want to enter in the file.
And I want to do it with ruby.
I've tried roo and spreadsheet but they don't seem able to actually edit the file, just create a new one and loosing all the formattin in the process.
It feels it should be simple to just edit the cells I want and save the file again but obviously it's more complex that I originally though(or I'm completely blind)
Any help is appreciated.
I'm learning ruby at the moment so that's why I would prefer a solution in ruby.
If you know there are better suited laguages for this feel free to point me in the right direction and I'll check it out.
Thanks in advance
Speaking from experience, there is no Ruby gem that would handle Excel files with all bells, whistles, macros and styling. It is a pity, because Excel is squarely the finest of Microsoft products. In my experience, spreadsheet library can import legacy data from Excel, LibreOffice Calc etc. (I'm not sure about Gnumeric).
As for your problem of getting data from Ruby to Excel, I suggest that you first save Ruby output as a separate file (spreadsheet, CSV, text...) and then teach Excel to import it (eg. using macros).
Another possibility is to abandon Excel for data processing tasks (and possibly keep it for data presentation tasks). Excel is great for presentation and simple data processing, but very bad for complex algorithms.
I wrote gems yzz and y_nelson, which I intended as Ruby replacement for spreadsheets. Yzz provides Ted Nelson's ZZ structures in Ruby (ZZ structure is an improved version of spreadsheet data structure) and y_nelson mixes it with Petri nets (because Petri nets are an improved version of Excel cell functions). Mathematically speaking, a spreadsheed is a hybrid between some sort of multidimensional orthogonal grid of data cells plus a Petri net execution engine. With y_nelson, I hope to bring dearly missed Excel functionality into Ruby, while at the same time moving one step towards better abstraction.