From: Peter Bailey Date: 2006-08-11T02:50:08+09:00 Subject: Re: using YAML? Eero Saynatkari wrote: > Peter Bailey wrote: >> I have a spreadsheet with 3 columns in it, and 174 rows. I need to >> cross-reference the items in one column with their corresponding entry >> in the other column. Here is a sample with the first 3 entries in this >> table. >> >> File Prefix Service Code Publication Title >> aacmc7p AACM00 Affirmative Action Compliance Manual >> acm059p BACM00 BNA/ACCA Compliance Manual >> acm061p BACM00 BNA/ACCA Compliance Manual, Interim Index >> Update >> >> I need to look at filenames coming into a directory, see what their >> "file prefix" is, based on column 1 above, and then notate in a separate >> variable the contents of column 2. I'm needing to ascertain what the >> company accounting code is for files being sent to our printer. >> >> Should I do this with just an array, or could I use YAML? > > Well, YAML is a serialisation format so it is really not > something you would use as runtime data storage. An Array > or a Hash would certainly work. > > If I misunderstood you and you were looking for a file format, > then YAML would work great. When you YAML.load the file, you > will get your Array/Hash and you can also YAML.dump data into > the file. The file format would look like this: > > --- > - > - acmcp7p > - AACM00 > - Affirmative # ... > - > - > # ... > > Or this: > > --- > - > prefix: acmcp7p > code: AACM00 > title: Affirmative #... > - > prefix: # ... > # ... > >> Thanks a lot, >> Peter Thanks, Eero. No, I wasn't looking for a file format. I just need to make an association between the items in the first column with their corresponding entry in the second column. I guess a hash makes more sense. I'd just read a bit about YAML, and, I was intrigued with the fact that it's simply text based and I could "parse" to it in some way. At least, that's how I understand it. I've got filenames coming into a directory. I need to look at the first 7 characters of those filenames and determine what the "charge" code is for the publication that's publishing that file. This is all for our company accounting system. Thanks again. -- Posted via http://www.ruby-forum.com/.