OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

In Need Of A Macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
capcap
Newbie
Newbie


Joined: 14 Jun 2004
Posts: 2

PostPosted: Mon Jun 14, 2004 4:59 am    Post subject: In Need Of A Macro Reply with quote

Hello,
I'm using "openoffice.org Calc Spreedsheet" version 1.0 and trying to write a macro to create a file that contains the following:

user create IBM000-CAP uid=IBM000-CAP,ou=000,o=IBM,dc=sis Conrad Phillips passw0rd
user modify IBM000-CAP password-valid yes
user modify IBM000-CAP account-valid yes
group modify grp-IBM000-sales-basic add IBM000-CAP

I have colums in my sheet as follows:

O - Contains " IBM "
OU - Contains " 000 "
Domain - Contains " dc=sis "
First - Contains " Conrad "
Last - Contains " Phillips "
ID - Contains " CAP "
PWD - Contains " passw0rd "
Group - Contains " sales-basic "

Can anyone help??
Back to top
View user's profile Send private message
Iannz
OOo Advocate
OOo Advocate


Joined: 14 Feb 2004
Posts: 494
Location: Christchurch, New Zealand

PostPosted: Tue Jun 15, 2004 3:00 pm    Post subject: Reply with quote

If I understand your problem correctly I don't think that you need a macro (unless you are doing this process very regularly).
Here is a process that I think should do what you want:
In a column (probably to the right of all the data) create a formula for concatenating the contents of the other cells. I usually use the ampersand operator e.g. =A1&","&B1 etc. Then copy this formula down.
Create a spreadsheet document
Go back to the original and copy the column you just created
Go to the new document
Edit > Paste Special... >
Make sure you uncheck formulas and that String is checked
Now File > Save As
And for file type choose Text
_________________
Cheers, Ian

http://wiki.services.openoffice.org/wiki/Extensions_development_basic a wiki about writing OpenOffice.org extensions.
Back to top
View user's profile Send private message
capcap
Newbie
Newbie


Joined: 14 Jun 2004
Posts: 2

PostPosted: Wed Jun 16, 2004 5:28 am    Post subject: Reply with quote

Not sure I understand the process you mentioned but here is some more information:

I do have to do this on a regular basis
I need to populate a database with 60,000 ficticious users for load testing

I eventually want to have a spreedsheet I can send to a customer, he will then fill in the
necessary information and send it back to me. I would then run the macro to extract the information into a text file which I can use to load the users into the database.

If I name my users cap01 for example. I can drag that column down and the spreedsheet automagicly continues to number them for me as cap02, cap03, etc....
I figured this would be the easiest way to do this but cannot figure this macro thing out. When I was running windows I was able to do this but wndows is no longer an option, my laptop is now linux.
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Jun 16, 2004 6:32 am    Post subject: Reply with quote

In my work using Visual FoxPro (a database program) I sometimes have to populate tables with fictional data.

Some years ago I wrote a set of functions. A "data generator" library. This library has a set of functions sort of like this....

Function DG_FirstName( Optional cGender as String )
Function DG_Middle()
Function DG_LastName()
Function DG_Address()
Function DG_City()
Function DG_State()
Function DG_Zip()
Function DG_Phone()
Function DG_CorpName()
....and possibly a few other functions....

(note, I'm using OOo Basic like syntax to illustrate what my functions do, since showing the actual VFP function signatures wouldn't be useful here.)

To make these functions work, I have several database tables that these functions randomly draw from. There is a table of first names. This has a "gender" colum with either M or F to indicate the gender of the name or whether the name can be used for either gender. If you call the DG_FirstName() function with no parameters, it returns a random first name. But you can request a specific gender, such as if you wish to prefix with "Mr.", "Mrs.", "Miss", "Ms.", etc. You could come up with your own name/title function that includes prefixes such as "Dr.", or a rank such as "Col.", "Corp.", etc.

The DG_LastName() function similarly randomly draws from a pool of last names.

The city, state, zip functions draw from a zip code table that gives a coordinated zip code for the state, but the city name may not exist in the state that is returned. (After all, this is just sample data.) The phone number function returns a phone number who's area code is coordinated with the state that was returned. So the data has some semblance of reality.

(Also the states returned can be Canadian provinces, or some US possessions.)

The DG_Address() function can sometimes return a random PO Box, or rural route. Sometimes a "care of" line, or "mail stop".

There are a handful of other functions, such as ones to generate random strings of digits, to spec. Useful for generating, say catalog numbers, etc. There is a random date function, again allowing you to specify allowable ranges, for instance, if you are generating someone's birthday, or date of certification. A middle name or initial may or may not be generated.

A "name to id" function can turn a name, such as "John Smith", into a regular ID, such as "SMITJOHN", again allowing specs such as minimum/maximum id length, etc. When trying to make an id from a name, you do some abbreviation tricks, such as first try removing vowels, selectively to get it to fit, or truncating parts of the name. For example, the above id is made up of four chars of last name, plus four chars of first name.

The DG_CorpName() function picks from several tables. There are three tables CorpName1, CorpName2, and CorpName3. One portion from each table is randomly selected, to generate names such as....

High Speed Industries Co.
Westside Publishing
Dolphin Specialties, Inc.
Alternative Associates Consolidated
AAA Productions Inc.
Granite Marketing Co.
Blue Flash Controls Company

Finally, I have a DG_RandomWord() function that returns a random word from a dictionary, which I got from the /usr/dict/words or /usr/share/dict/words file found on many Linux systems.

These ideas may help you to write some data generator functions.

If I get time I will try to build the following and send it to the maintainer of OOoMacros.org....
I'll try to make a spreadsheet, that has each of my tables as a seperate sheet, and then replicate the above functions in OOo Basic so that it becomes a general purpose data generator tool whose functions you can use. If I get a chance to do that, I'll post a reply here.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Jul 20, 2004 7:12 am    Post subject: Reply with quote

DannyB wrote:
If I get time I will try to build the following and send it to the maintainer of OOoMacros.org....


I finally ported the data generator functions. I announced them in this thread....

Announce: Danny's DataGen Tools
http://www.oooforum.org/forum/viewtopic.php?t=10973
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group