Exanding an array into another file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exanding an array into another file.
# 8  
Old 12-13-2018
If your input data is processed in sequence, a text file is the perfect form. And the shell is great in handling text files. (An array is good for random access.)
A simple "echo" demo:
Code:
# read two space-separated columns from stdin into two variables
while read ROW_NUMBER SKU_NAME
do
  echo "ROW_NUMBER=$ROW_NUMBER and SKU_NAME=$SKU_NAME"
done < arrayfile
# the stdin of the while-do-done block is from arrayfile

The read reads one line from a text file. The while will terminate the loop if the read was unsucessful i.e. at the end of the input.
Now with your application:
Code:
while read ROW_NUMBER SKU_NAME
do
    osascript <<EOD
    tell application "Microsoft Excel"
        activate    
        make new hyperlink of cell "B${ROW_NUMBER}" at active sheet with properties {address:"http://switchauto.tigroup.ca/SCL_Preflight_Report_Page/$SKUNAME_report.html"}
        set theLeft to left position of cell "A${ROW_NUMBER}"
        set theTop to top of cell "A${ROW_NUMBER}"
        set currentWorkbook to workbook 1
        tell currentWorkbook
            tell worksheet 1
                set pictureShape to make new shape at the beginning with properties {height:"72", width:"72", left position:0, top:theTop, placement:placement move}
                user picture pictureShape picture file "Macintosh HD:Library:WebServer:Documents:FilesForExcel:Jpeg:${SKU_NAME}_02.jpeg"
            end tell
EOD
# the EOD must be at the very left
done < arrayfile

The braces in ${SKU_NAME} encapsulate the variable name, so ${SKU_NAME}_02 is the variable's value and the string _02 appended.
This User Gave Thanks to MadeInGermany For This Post:
# 9  
Old 12-13-2018
Thanks very much!!

I'll give that a try and let you know how it works!
Thanks again!!!
# 10  
Old 01-04-2019
Hi I have these scripts working fine now I set up a hot folder that has the script attached and it is inserting the thumbnails and the HTML links beautifully

Thanks for your help!!!Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

2. Shell Programming and Scripting

Search if file exists for a file pattern stored in array

Hi experts, I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg searchfile.dat will have abc303 xyz123 i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz The following code... (2 Replies)
Discussion started by: 100bees
2 Replies

3. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

4. Shell Programming and Scripting

Compare file to array, replace with corresponding second array

ok, so here is the issue, I have 2 arrays. I need to be able to create a loop that will find ${ARRAY1 in the text doc, and replace it with ${ARRAY2 then write the results. I already have that working. The problem is, I need it to do that same result across however many items are in the 2... (2 Replies)
Discussion started by: gentlefury
2 Replies

5. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

6. Shell Programming and Scripting

Array in Perl - Detect several file to be in one array

Hi everyone I have one question about using array in perl. let say I have several log file in one folder.. example test1.log test2.log test3.log and the list goes on.. how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies

7. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

8. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

9. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

10. Shell Programming and Scripting

create array holding characters from sring then echo array.

Hi, I wish to store $string1 in $string1array a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: ... (5 Replies)
Discussion started by: rorey_breaker
5 Replies
Login or Register to Ask a Question